Skip to content
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

Stage2 compile error improvements #12016

Merged
merged 10 commits into from
Jul 7, 2022
Merged

Conversation

Vexu
Copy link
Member

@Vexu Vexu commented Jul 6, 2022

No description provided.

@Vexu Vexu force-pushed the stage2-compile-errors branch from 25beac6 to 77416c4 Compare July 6, 2022 20:35
Comment on lines +14 to +15
// :2:20: error: expected error set type, found 'u8'
// :6:31: error: expected error set type, found 'u16'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have lost the handy note:

note: `||` merges error sets; `or` performs boolean OR

this is beneficial because || in other languages is or.

I haven't been checking too closely on your other commits, have you been making sure that useful error notes are preserved when marking these test cases as "passing" for stage2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note is still there but only when both operands are bools.

src/Zir.zig Outdated Show resolved Hide resolved
@Vexu Vexu force-pushed the stage2-compile-errors branch from 77416c4 to 5007f72 Compare July 7, 2022 07:50
@andrewrk
Copy link
Member

andrewrk commented Jul 7, 2022

stage2: make line field of @src runtime known

can you explain more why this change?

@andrewrk
Copy link
Member

andrewrk commented Jul 7, 2022

I'm going to merge because I trust your judgement and these are some really nice improvements. We can chat about @src later :-)

@andrewrk andrewrk merged commit 0c78ece into ziglang:master Jul 7, 2022
@Vexu
Copy link
Member Author

Vexu commented Jul 7, 2022

can you explain more why this change?

It is to stop users from doing comptime logic on the line number and then moving the function during an incremental update, it was discussed in the original proposal #2029 (comment).

test {
    if (@src().line == 4) @compileError("don't put me on line 4");
}

The alternative is to make all the fields comptime known but then invalidate the function if it is moved.

TUSF pushed a commit to TUSF/zig that referenced this pull request May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants