| ... | @@ -361,24 +361,21 @@ fn varDecl( | ... | @@ -361,24 +361,21 @@ fn varDecl( |
| 361 | return &sub_scope.base; | 361 | return &sub_scope.base; |
| 362 | }, | 362 | }, |
| 363 | .Keyword_var => { | 363 | .Keyword_var => { |
| 364 | const alloc = if (node.getTrailer("type_node")) |type_node| a: { | 364 | const var_data: struct { result_loc: ResultLoc, alloc: *zir.Inst } = if (node.getTrailer("type_node")) |type_node| a: { |
| 365 | const type_inst = try typeExpr(mod, scope, type_node); | 365 | const type_inst = try typeExpr(mod, scope, type_node); |
| 366 | break :a try addZIRUnOp(mod, scope, name_src, .alloc, type_inst); | 366 | const alloc = try addZIRUnOp(mod, scope, name_src, .alloc, type_inst); |
| 367 | } else try addZIRNoOp(mod, scope, name_src, .alloc_inferred); | 367 | break :a .{ .alloc = try addZIRUnOp(mod, scope, name_src, .alloc, type_inst), .result_loc = .{ .ptr = alloc } }; |
| 368 | const result_loc = r: { | 368 | } else a: { |
| 369 | if (node.getTrailer("type_node")) |type_node| { | 369 | const alloc = try addZIRNoOp(mod, scope, name_src, .alloc_inferred); |
| 370 | break :r ResultLoc{ .ptr = alloc }; | 370 | break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc.castTag(.alloc_inferred).? } }; |
| 371 | } else { | | |
| 372 | break :r ResultLoc{ .inferred_ptr = alloc.castTag(.alloc_inferred).? }; | | |
| 373 | } | | |
| 374 | }; | 371 | }; |
| 375 | const init_inst = try expr(mod, scope, result_loc, init_node); | 372 | const init_inst = try expr(mod, scope, var_data.result_loc, init_node); |
| 376 | const sub_scope = try block_arena.create(Scope.LocalPtr); | 373 | const sub_scope = try block_arena.create(Scope.LocalPtr); |
| 377 | sub_scope.* = .{ | 374 | sub_scope.* = .{ |
| 378 | .parent = scope, | 375 | .parent = scope, |
| 379 | .gen_zir = scope.getGenZIR(), | 376 | .gen_zir = scope.getGenZIR(), |
| 380 | .name = ident_name, | 377 | .name = ident_name, |
| 381 | .ptr = alloc, | 378 | .ptr = var_data.alloc, |
| 382 | }; | 379 | }; |
| 383 | return &sub_scope.base; | 380 | return &sub_scope.base; |
| 384 | }, | 381 | }, |