authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-29 13:43:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-29 13:43:03-07:00
log861b784454aa2ed3365b31dc18f9f569bc637703
treebad3969aad34da935d24dce392b05419d2adda42
parentbe9b490f844277237bd0b60ba6120689723243b3

AstGen: fix incorrectly using decl_val/decl_ref

in identifiers rather than directly referencing the instructions.

1 files changed, 8 insertions(+), 13 deletions(-)

src/AstGen.zig+8-13
......@@ -6372,11 +6372,9 @@ fn identifier(
63726372
63736373 if (local_val.name == name_str_index) {
63746374 local_val.used = true;
6375 // Captures of non-locals need to be emitted as decl_val or decl_ref.
6376 // This *might* be capturable depending on if it is comptime known.
6377 if (hit_namespace == 0) {
6378 return rvalue(gz, rl, local_val.inst, ident);
6379 }
6375 // Locals cannot shadow anything, so we do not need to look for ambiguous
6376 // references in this case.
6377 return rvalue(gz, rl, local_val.inst, ident);
63806378 }
63816379 s = local_val.parent;
63826380 },
......@@ -6384,14 +6382,11 @@ fn identifier(
63846382 const local_ptr = s.cast(Scope.LocalPtr).?;
63856383 if (local_ptr.name == name_str_index) {
63866384 local_ptr.used = true;
6387 if (hit_namespace != 0) {
6388 if (local_ptr.maybe_comptime)
6389 break
6390 else
6391 return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{
6392 try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}),
6393 try astgen.errNoteNode(hit_namespace, "crosses namespace boundary here", .{}),
6394 });
6385 if (hit_namespace != 0 and !local_ptr.maybe_comptime) {
6386 return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{
6387 try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}),
6388 try astgen.errNoteNode(hit_namespace, "crosses namespace boundary here", .{}),
6389 });
63956390 }
63966391 switch (rl) {
63976392 .ref, .none_or_ref => return local_ptr.ptr,