-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disallow local term references in staged types #16362
Conversation
5e0bc19
to
aa1d6c3
Compare
@@ -206,6 +206,8 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( | |||
tryHeal(prefix.symbol, tp, pos) | |||
case _ => | |||
mapOver(tp) | |||
case tp @ TermRef(NoPrefix, _) if !tp.symbol.isStatic && level > levelOf(tp.symbol) => |
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.
why do we check level >
here but level !=
in healTypeOfTerm
?
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.
In healTypeOfTerm
we are looking for terms that are used in other stages. Terms must be used at the same stage they are defined, hence the level !=
.
For types the rules are a bit different. For types in general it is always safe to use the type in a previous stage and one needs a type Type[T]
for generic types if it is used in a future stage. This is in general where the >
comes in for type. But in this particular case, we have a type reference to a local variable that will not exist in the next stage and we cannot create a valid Type[T]
for it. Therefore it emmits an error.
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.
Thanks for the explanation, I think it'd be helpful to add something like that as a comment in the code
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.
Added to the 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.
A more detailed comment would be helpful, otherwise LGTM.
aa1d6c3
to
7d731dc
Compare
7d731dc
to
df0d9ea
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.
Otherwise LGTM.
Co-authored-by: Guillaume Martres <smarter@ubuntu.com>
Fixes #15917
Fixes #16355