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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30387,7 +30387,7 @@ fn coerceExtra(

// Add notes about function return type
if (opts.is_ret and
!zcu.test_functions.contains(zcu.funcInfo(sema.owner.unwrap().func).owner_nav))
!zcu.test_functions.contains(zcu.funcInfo(sema.func_index).owner_nav))
{
const ret_ty_src: LazySrcLoc = .{
.base_node_inst = sema.getOwnerFuncDeclInst(),
Expand Down Expand Up @@ -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.

const cau = if (func_info.generic_owner == .none) cau: {
break :cau ip.getNav(func_info.owner_nav).analysis_owner.unwrap().?;
} else cau: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fn foo() fn () void {
return struct {};
}
comptime {
_ = foo();
}

// error
// backend=stage2
// target=native
//
// :2:12: error: expected type 'fn () void', found 'type'
// :1:10: note: function return type declared here
// :5:12: note: called from here
Loading