-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
stage2: detect ambiguous decl references #8921
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
|
d94013e
to
c488cc7
Compare
9eaaa85
to
5848850
Compare
std: fix compile errors from this change. This is a stage1 bug.
@@ -5347,6 +5349,7 @@ fn forExpr( | |||
.name = index_name, | |||
.ptr = index_ptr, | |||
.token_src = index_token, | |||
.is_comptime = parent_gz.force_comptime, |
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.
Is this correct?
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 should use is_inline
since the index is also comptime known for inline loops. Also sorry for not answering sooner.
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.
Btw @andrewrk, @SpexGuy What should the correct behavior be for
pub fn main() void {
comptime var i = 0;
inline while (i < 5) : (i+=1) {
const S = struct {
fn print() void {
std.debug.print("loop {d}\n", .{i});
}
};
S.print();
}
}
Stage1 prints
loop 5
loop 5
loop 5
loop 5
loop 5
but I think most people would assume it to print
loop 0
loop 1
loop 2
loop 3
loop 4
This also found some compile errors in std, so I fixed them.
Putting this as a separate pr as my work on unused vars as #8920 is blocking that, but not this.