authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-19 20:57:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-19 20:57:06-07:00
log5b597a16c6c4ac36a8d2004d5eeed62c38c75253
treefe6c14025e5b4337134cbf29b972321e55908047
parentd8560edc2941016a12a03df36035cabd537dde77

stage2: fix not setting up ZIR arg instruction correctly

This is a regression from when I briefly flirted with changing how arg ZIR instructions work in this branch, and then failed to revert it correctly.

1 files changed, 6 insertions(+), 2 deletions(-)

src/Module.zig+6-2
...@@ -1340,13 +1340,15 @@ fn astgenAndSemaFn(...@@ -1340,13 +1340,15 @@ fn astgenAndSemaFn(
1340 const name_token = param.name_token.?;1340 const name_token = param.name_token.?;
1341 const src = token_starts[name_token];1341 const src = token_starts[name_token];
1342 const param_name = try mod.identifierTokenString(&gen_scope.base, name_token);1342 const param_name = try mod.identifierTokenString(&gen_scope.base, name_token);
1343 const arg = try decl_arena.allocator.create(zir.Inst.NoOp);1343 const arg = try decl_arena.allocator.create(zir.Inst.Arg);
1344 arg.* = .{1344 arg.* = .{
1345 .base = .{1345 .base = .{
1346 .tag = .arg,1346 .tag = .arg,
1347 .src = src,1347 .src = src,
1348 },1348 },
1349 .positionals = .{},1349 .positionals = .{
1350 .name = param_name,
1351 },
1350 .kw_args = .{},1352 .kw_args = .{},
1351 };1353 };
1352 gen_scope.instructions.items[i] = &arg.base;1354 gen_scope.instructions.items[i] = &arg.base;
...@@ -3929,7 +3931,9 @@ pub fn validateVarType(mod: *Module, scope: *Scope, src: usize, ty: Type) !void...@@ -3929,7 +3931,9 @@ pub fn validateVarType(mod: *Module, scope: *Scope, src: usize, ty: Type) !void
3929/// Identifier token -> String (allocated in scope.arena())3931/// Identifier token -> String (allocated in scope.arena())
3930pub fn identifierTokenString(mod: *Module, scope: *Scope, token: ast.TokenIndex) InnerError![]const u8 {3932pub fn identifierTokenString(mod: *Module, scope: *Scope, token: ast.TokenIndex) InnerError![]const u8 {
3931 const tree = scope.tree();3933 const tree = scope.tree();
3934 const token_tags = tree.tokens.items(.tag);
3932 const token_starts = tree.tokens.items(.start);3935 const token_starts = tree.tokens.items(.start);
3936 assert(token_tags[token] == .identifier);
39333937
3934 const ident_name = tree.tokenSlice(token);3938 const ident_name = tree.tokenSlice(token);
3935 if (mem.startsWith(u8, ident_name, "@")) {3939 if (mem.startsWith(u8, ident_name, "@")) {