Commit 4585cb1e2f
Changed files (3)
test
cases
compile_errors
src/AstGen.zig
@@ -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;
src/Sema.zig
@@ -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
test/cases/compile_errors/@export_with_undeclared_identifier.zig
@@ -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'