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

Sema: fix check for whether current AnalUnit is a test function #21766

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

Vexu
Copy link
Member

@Vexu Vexu commented Oct 21, 2024

Closes #21159

@mlugg
Copy link
Member

mlugg commented Oct 21, 2024

I think this fix is wrong -- the return type related logic in coerceExtra should be looking at sema.func_index, not sema.owner, so that it works correctly through inline calls. In fact, you can see that the compile error test you added doesn't have a return type declared here note, but it should. (I'm the one who did this wrong in the first place, sorry!)

@Vexu
Copy link
Member Author

Vexu commented Oct 21, 2024

Is getOwnerFuncDeclInst also wrong or should this not be using it?

@mlugg
Copy link
Member

mlugg commented Oct 21, 2024

This shouldn't be using it. (That leaves only one use site for that function, in zirBuiltinExtern; feel free to inline it there if you want.)

src/Sema.zig Outdated
@@ -38730,8 +38730,7 @@ fn getOwnerCauDeclInst(sema: *Sema) InternPool.TrackedInst.Index {
fn getOwnerFuncDeclInst(sema: *Sema) InternPool.TrackedInst.Index {
const zcu = sema.pt.zcu;
const ip = &zcu.intern_pool;
const func = sema.owner.unwrap().func;
const func_info = zcu.funcInfo(func);
const func_info = zcu.funcInfo(sema.func_index);
Copy link
Member

@mlugg mlugg Oct 21, 2024

Choose a reason for hiding this comment

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

No, getOwnerFuncDeclInst was correct, and the old behavior was necessary for the other call site (for reasons relating to incremental compilation). You could make this new version under getCurrentFuncDeclInst.

@Vexu Vexu merged commit 9ffee5a into ziglang:master Oct 24, 2024
10 checks passed
@Vexu Vexu deleted the test-fn-check-fix branch October 24, 2024 10:34
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.

Compiler crash: panic: access of union field 'func' while field 'cau' is active
2 participants