-
Notifications
You must be signed in to change notification settings - Fork 82
rewrote subtype semantics of start to simulate the semantics of the interpreter. Fixes #2496 #2499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…nterpreter. Fixes #2496
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2499 +/- ##
=======================================
Coverage 47% 47%
- Complexity 6705 6711 +6
=======================================
Files 791 791
Lines 65239 65239
Branches 9769 9769
=======================================
+ Hits 30916 30933 +17
+ Misses 31909 31896 -13
+ Partials 2414 2410 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@jurgenvinju Added the tests as requested in #2496 (and an additional one), but two of them still fail. I had a look, but did not see an obvious solution. |
… different (incomparable) type from A
…e of an aadt without exceptions
Finish adding the syntax role to start types
jurgenvinju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked for funny side effects. Still not working!
| !isTerminalSym(sym), | ||
| tsym := s.getType(sym), | ||
| isNonTerminalAType(tsym), | ||
| stp := getSyntaxType(removeChainRule(tsym), s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check later: what is remove chain rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulKlint I don't remember chain rule unwrapping as a feature for production fields. Do we have this in the interpreter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from the behavior of the interpreter
src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc
Outdated
Show resolved
Hide resolved
|
This PR doesn't get through any type-checker test with a function or constructor call in it. My internal notes, for later: The changes made only pertain to the start symbol/atype so that is a surprise. The intersection between start symbol and function calls happens probably when filtering the overloaded candidates. Each candidate's parameters are matched using All candidates are always filtered currently. So This points to a new bug introduced into asubtype. If not, then If asubtype is broken then I should definitely check aglb and alub too. Also it would be interesting to see if these three functions can be randomly tested like their counterparts in Type... |
|
Everything succeeded at e6fbb9e. What motivated the changes made since then? |
| } | ||
| reportMissingNonTerminalCases(current, overloads, validOverloads, actuals, s); | ||
| next_cons: | ||
| for(ovl: <key,idRole, tp> <- overloads){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about reusing a tp variable here since it occurs more often in the code.
src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc
Outdated
Show resolved
Hide resolved
|
@toinehartman it didn't work for me at that commit. That's one reason I kept searching for better solutions. While searching I also saw that start's top field implementation was scattered, and the top field test was exactly the failing test I was working on. So now the top field handling is all done in the collect for the Start modifier. In the meantime my failing test was due to an old open typepal project. 🙈 |
…backend, and removed all special-case handling of the start symbol from the checker code
…s the module interface, from now on
…mmon/general case
| bool isADTAType(aparameter(_,AType tvb)) = isADTAType(tvb); | ||
| bool isADTAType(aadt(_,_,_)) = true; | ||
| bool isADTAType(areified(_)) = true; | ||
| bool isADTAType(\start(AType s)) = isADTAType(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my doubts here. What does it mean to be a ADTAType? Should it be obly aadt's? Then this should be false for start. If it should be all left hand side of syntax rules, then it should be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps @PaulKlint can answer this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note: this line is changed, not removed; look at the full diff)
| c.define("<aStartSym>", nonterminalId(), current, st); | ||
| startProd = defType(aprod(prod(aStartSym, [nonterminalType[alabel="top"]]))); | ||
| sPos = current@\loc.top(current@\loc.offset, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit tricky. Replace by original loc + modifier.
| private AType computeFieldAssignableType(Statement current, AType receiverType, Tree field, str operator, AType rhs, loc scope, Solver s){ | ||
| //println("computeFieldAssignableType: <current>"); | ||
| fieldName = unescape("<field>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So where is "top" declared these days?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rascal/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc
Lines 137 to 139 in 37715c1
| fieldDef = defType(nonterminalType[alabel="top"]); | |
| tPos = current@\loc.top(current@\loc.offset + 1, 1); | |
| c.define("top", fieldId(), tPos, fieldDef); |
|
Overall looks good. All these "notes to self" are noise and complicate this review. Minor concern: at the moment we do not support a I cannot assess whether this new code will break the code generator. |
toinehartman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I like how this removes all kinds of special casing, e.g. around the top field.
I have a couple of minor comments.
| for(AType adtType <- allStarts){ | ||
| syntaxDefinitions[\start(adtType)] = achoice(\start(adtType), { prod(\start(adtType), [definedLayout, adtType[alabel="top"], definedLayout]) }); | ||
| // TODO JV: there are more places where layout is added to the start non-terminal... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this TODO indicate more work to in this PR before merging?
| bool isADTAType(aparameter(_,AType tvb)) = isADTAType(tvb); | ||
| bool isADTAType(aadt(_,_,_)) = true; | ||
| bool isADTAType(areified(_)) = true; | ||
| bool isADTAType(\start(AType s)) = isADTAType(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps @PaulKlint can answer this?
| bool isADTAType(aparameter(_,AType tvb)) = isADTAType(tvb); | ||
| bool isADTAType(aadt(_,_,_)) = true; | ||
| bool isADTAType(areified(_)) = true; | ||
| bool isADTAType(\start(AType s)) = isADTAType(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note: this line is changed, not removed; look at the full diff)
| private AType computeFieldAssignableType(Statement current, AType receiverType, Tree field, str operator, AType rhs, loc scope, Solver s){ | ||
| //println("computeFieldAssignableType: <current>"); | ||
| fieldName = unescape("<field>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rascal/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectSyntaxDeclaration.rsc
Lines 137 to 139 in 37715c1
| fieldDef = defType(nonterminalType[alabel="top"]); | |
| tPos = current@\loc.top(current@\loc.offset + 1, 1); | |
| c.define("top", fieldId(), tPos, fieldDef); |
| msg = error("Constructor `<ovl1.atype.alabel>` is overloaded, maybe<qualifyHint><argHint>", | ||
| msg = error("Constructor `<ovl1.atype.alabel>` is overloaded, maybe <qualifyHint><argHint>", | ||
| current@\loc); | ||
| iprintln(overloads); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be removed?
| } else | ||
| continue; | ||
| } | ||
| // println("require: <i>, <formalTypesU[i]> -- <aiU>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the compiler have a verbose/debug flag that we can hide this under?
start[A]declared asA#2496 by redefining alub, aglb and asubtype such that start symbols are exclusively subtypes of themselves andTreeandnode.syntaxRolefield toAType::\startto make it more compatible with aadt and avoid case distinctions later in the compiler.startmodifier is detected on a syntax rule forX, the collector:"start[X]"asAType::start(X, contextFreeSyntax())prod(X, [label(X, "top")]. _),start[X].topwith typeX.startkeyword is used in three ways. This avoids the multiplekey problem for the mapping between facts/types and their declaration locations.startas a whole, for the generated start type.sinstartonly, for the generated rule.tinstartonly: for the generated field.start[A]andAand the existence and type of thetopfield of astart[A]non-terminal (which isA)