-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Swift: clean up VarDecl
, NamedPattern
and SwitchStmt
interactions
#14567
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
Conversation
* `variables` under `CaseStmt` are now AST children, which solves orphan `VarDecl`s in that case * reordered `CaseStmt` AST children to be `labels > variables > body` (was `body > labels`) * made `NamedPattern::getVarDecl` an extracted property instead of `getName` * The above led to duplicate DB entities because of a quirk in the Swift compiler code. This is solved by tweaking the extraction of `variables` under `CaseStmt` to not use `getCaseBodyVariables`.
294ae67
to
2f0ee12
Compare
@@ -1,3 +1,4 @@ | |||
| var_decls.swift:2:7:2:7 | i | var_decls.swift:2:7:2:7 | i | |
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.
it's actually weird that this was missing! This is the for
loop i
variable, which is distinct from the i
variable introduced after the loop.
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.
ah, wait, this is a parent pattern thing, I don't fully know what to make of this 😆
90516d9
to
6538a76
Compare
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.
@MathiasVP the DB scripts look good to me!
Awesome. In that case I'll approve the merge so that we can merge it 🎉 (because the code changes LGTM as well!) |
# 85| [ConcreteVarDecl] b | ||
# 85| Type = Int | ||
# 88| [ConcreteVarDecl] a | ||
# 88| Type = Int | ||
# 92| [ConcreteVarDecl] x | ||
# 92| Type = (Int) | ||
# 95| [ConcreteVarDecl] x | ||
# 95| Type = Int |
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.
still quite a number of orphaned (or maybe duplicate?) var decls here, eh?
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 like it, yeah
variables
underCaseStmt
are now AST children, which solves orphanVarDecl
s in that caseCaseStmt
AST children to belabels > variables > body
(wasbody > labels
)NamedPattern::getVarDecl
an extracted property instead ofgetName
The above was introducing several
VarDecl
duplications, asCaseStmt::getCaseBodyVariables
,NamedPattern::getVarDecl
andDeclRefExpr::getDecl
were all actually returning distinctVarDecl
instances. It turns out,VarDecl
has agetCanonicalVarDecl()
to get the true unique variable declaration 🤷 This is now applied at a fundamental level in the the dispatcher, so that any fetching of a variable declaration done anywhere in any translator will pass through this.