mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
AstGen: fix @export with undeclared identifier crashing
This required a third `if (found_already == null)` in another place in AstGen.zig for this special case of `@export`. Fixes #17188
This commit is contained in:
parent
3fc7413574
commit
4585cb1e2f
@ -8294,6 +8294,10 @@ fn builtinCall(
|
||||
},
|
||||
.top => break,
|
||||
};
|
||||
if (found_already == null) {
|
||||
const ident_name = try astgen.identifierTokenString(ident_token);
|
||||
return astgen.failNode(params[0], "use of undeclared identifier '{s}'", .{ident_name});
|
||||
}
|
||||
},
|
||||
.field_access => {
|
||||
const namespace_node = node_datas[params[0]].lhs;
|
||||
|
||||
@ -6412,7 +6412,7 @@ fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: InternPoo
|
||||
}
|
||||
namespace = mod.namespacePtr(namespace).parent.unwrap() orelse break;
|
||||
}
|
||||
unreachable; // AstGen detects use of undeclared identifier errors.
|
||||
unreachable; // AstGen detects use of undeclared identifiers.
|
||||
}
|
||||
|
||||
/// This looks up a member of a specific namespace. It is affected by `usingnamespace` but
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
export fn a() void {
|
||||
@export(bogus, .{ .name = "bogus_alias" });
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:13: error: use of undeclared identifier 'bogus'
|
||||
Loading…
x
Reference in New Issue
Block a user