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
[SR-284] Strange error caused by let/var at specific place in main file. #42906
Comments
In a main source file, declarations are evaluated in groups, but any actual code has to be run immediately, and top-level variables behave like locals rather than globals. That means we try to type-check One way to fix this might be to parse the entire file up front, but then mark the declarations as "off-limits" somehow for type-checking purposes. That won't work for things like overload resolution, though. |
More subtly, |
I think the restriction is correct, but the error message is lousy. This isn't the first time it's been filed. |
(and I don't just mean Jens cloning Radars into JIRA. :-) ) |
Note that this compiles:
|
Yes, that's compiled as
each block of which is fine given the previous ones. |
Dups include unsafe behavior caused by this. |
I didn't find any radars with unsafe behavior, but I suspect its caused by DI not working across files. In any case that problem already exists even with the old intertwined parsing model. |
Additional Detail from JIRA
md5: 49c6b20edc7481c19a41e118ce88ca23
is duplicated by:
relates to:
Issue Description:
The unrelated constant notEvenUsed somehow causes the error on struct S. The error will disappear if the constant is moved to another line or removed.
(This happens only in the main file.)
The text was updated successfully, but these errors were encountered: