Repository navigation
Fix self-referential variable initialization and pattern match - #3028
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3028 +/- ##
=======================================
Coverage 46% 46%
- Complexity 6933 6938 +5
=======================================
Files 851 851
Lines 69340 69340
Branches 10105 10105
=======================================
+ Hits 32164 32180 +16
+ Misses 34740 34729 -11
+ Partials 2436 2431 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0c0f6d8 to
c32da79
Compare
c32da79 to
1242ea9
Compare
1242ea9 to
97a9a7f
Compare
Co-authored-by: Sung-Shik Jongmans <sung-shik.jongmans@swat.engineering>
| c.report(error(initial, "Right-hand side of assignment does not always have a value")); | ||
| } | ||
| } | ||
| storeDisallowUseOfDef(var.name, initial, c); |
There was a problem hiding this comment.
Prohibit int i = i; in functions
| c.pop(patternContainer); | ||
|
|
||
| for (p <- patternVars) { | ||
| storeDisallowUseOfDef(p, expression, c); |
| // println("foundUseDefs:"); | ||
| // for(<u, d> <- foundUseDefs){ | ||
| // println("<readFile(u)>:<u> ==\> <d>"); | ||
| // } |
There was a problem hiding this comment.
Disabled debug printing
| if(names[v]?) occ = names[v]; else throw "Name <v> not found in tree"; | ||
| if(!occ[def]?) throw "Missing define <def> for name <v>"; | ||
| if(!occ[def]?) { | ||
| println("Missing define <def> for name <v>"); |
There was a problem hiding this comment.
Print all failure reasons and return false, instead of throwing on the first assertion
| c.report(error(initial, "Right-hand side of assignment does not always have a value")); | ||
| } | ||
| } | ||
| storeDisallowUseOfDef(var.name, initial, c); |
There was a problem hiding this comment.
Prohibit int i = i at module level
PaulKlint
left a comment
There was a problem hiding this comment.
I like this down-to-earth approach. It is less sophisticated than the previous solution but it gets the job done in a much simpler and less invasive way.
One concern is that we never cleanup this information, see comment. We should at least discuss this.
|



In
int i = iandi := i, the right-hand-sideiwould be marked as a use of the definition on theleft-hand-side, while that is incorrect. This PR fixes that.After initially trying to solve this with modified scoping and an extension to typepal (usethesource/typepal#71), which turned out to be quite invasive across the type-checker, we opted for a more local approach. the result is this PR. Most of the changes consist of tests, and I pointed out the actual fix in comments.
Integration test: https://github.com/usethesource/rascal-core-big-tests/actions/runs/46883603008
Closes #2264.
Closes #2783.