commit 861b784454aa2ed3365b31dc18f9f569bc637703 (tree)
parent be9b490f844277237bd0b60ba6120689723243b3
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 29 Aug 2021 13:43:03 -0700
AstGen: fix incorrectly using decl_val/decl_ref
in identifiers rather than directly referencing the instructions.
Diffstat:
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/AstGen.zig b/src/AstGen.zig
@@ -6372,11 +6372,9 @@ fn identifier(
if (local_val.name == name_str_index) {
local_val.used = true;
- // Captures of non-locals need to be emitted as decl_val or decl_ref.
- // This *might* be capturable depending on if it is comptime known.
- if (hit_namespace == 0) {
- return rvalue(gz, rl, local_val.inst, ident);
- }
+ // Locals cannot shadow anything, so we do not need to look for ambiguous
+ // references in this case.
+ return rvalue(gz, rl, local_val.inst, ident);
}
s = local_val.parent;
},
@@ -6384,14 +6382,11 @@ fn identifier(
const local_ptr = s.cast(Scope.LocalPtr).?;
if (local_ptr.name == name_str_index) {
local_ptr.used = true;
- if (hit_namespace != 0) {
- if (local_ptr.maybe_comptime)
- break
- else
- return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{
- try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}),
- try astgen.errNoteNode(hit_namespace, "crosses namespace boundary here", .{}),
- });
+ if (hit_namespace != 0 and !local_ptr.maybe_comptime) {
+ return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{
+ try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}),
+ try astgen.errNoteNode(hit_namespace, "crosses namespace boundary here", .{}),
+ });
}
switch (rl) {
.ref, .none_or_ref => return local_ptr.ptr,