| ... | ... | @@ -1460,6 +1460,7 @@ fn arrayInitExpr( |
| 1460 | 1460 | mem.eql(u8, tree.tokenSlice(tree.nodeMainToken(array_type.ast.elem_count)), "_")) |
| 1461 | 1461 | { |
| 1462 | 1462 | const len_inst = try gz.addInt(array_init.ast.elements.len); |
| 1463 | const saved_cursor = astgen.saveSourceCursor(); |
| 1463 | 1464 | const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); |
| 1464 | 1465 | if (array_type.ast.sentinel == .none) { |
| 1465 | 1466 | const array_type_inst = try gz.addPlNode(.array_type, type_expr, Zir.Inst.Bin{ |
| ... | ... | @@ -1468,6 +1469,7 @@ fn arrayInitExpr( |
| 1468 | 1469 | }); |
| 1469 | 1470 | break :inst .{ array_type_inst, elem_type }; |
| 1470 | 1471 | } else { |
| 1472 | astgen.restoreSourceCursor(saved_cursor); |
| 1471 | 1473 | const sentinel_node = array_type.ast.sentinel.unwrap().?; |
| 1472 | 1474 | const sentinel = try comptimeExpr(gz, scope, .{ .rl = .{ .ty = elem_type } }, sentinel_node, .array_sentinel); |
| 1473 | 1475 | const array_type_inst = try gz.addPlNode( |
| ... | ... | @@ -1729,6 +1731,7 @@ fn structInitExpr( |
| 1729 | 1731 | mem.eql(u8, tree.tokenSlice(tree.nodeMainToken(array_type.ast.elem_count)), "_"); |
| 1730 | 1732 | if (struct_init.ast.fields.len == 0) { |
| 1731 | 1733 | if (is_inferred_array_len) { |
| 1734 | const saved_cursor = astgen.saveSourceCursor(); |
| 1732 | 1735 | const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); |
| 1733 | 1736 | const array_type_inst = if (array_type.ast.sentinel == .none) blk: { |
| 1734 | 1737 | break :blk try gz.addPlNode(.array_type, type_expr, Zir.Inst.Bin{ |
| ... | ... | @@ -1736,6 +1739,7 @@ fn structInitExpr( |
| 1736 | 1739 | .rhs = elem_type, |
| 1737 | 1740 | }); |
| 1738 | 1741 | } else blk: { |
| 1742 | astgen.restoreSourceCursor(saved_cursor); |
| 1739 | 1743 | const sentinel_node = array_type.ast.sentinel.unwrap().?; |
| 1740 | 1744 | const sentinel = try comptimeExpr(gz, scope, .{ .rl = .{ .ty = elem_type } }, sentinel_node, .array_sentinel); |
| 1741 | 1745 | break :blk try gz.addPlNode( |
| ... | ... | @@ -3436,6 +3440,7 @@ fn assignDestructureMaybeDecls( |
| 3436 | 3440 | const is_comptime = full.comptime_token != null or gz.is_comptime; |
| 3437 | 3441 | const value_is_comptime = tree.nodeTag(full.ast.value_expr) == .@"comptime"; |
| 3438 | 3442 | |
| 3443 | const saved_cursor = astgen.saveSourceCursor(); |
| 3439 | 3444 | // When declaring consts via a destructure, we always use a result pointer. |
| 3440 | 3445 | // This avoids the need to create tuple types, and is also likely easier to |
| 3441 | 3446 | // optimize, since it's a bit tricky for the optimizer to "split up" the |
| ... | ... | @@ -3563,6 +3568,7 @@ fn assignDestructureMaybeDecls( |
| 3563 | 3568 | if (any_lvalue_expr) { |
| 3564 | 3569 | // At least one variable was an lvalue expr. Iterate again in order to |
| 3565 | 3570 | // evaluate the lvalues from within the possible block_comptime. |
| 3571 | astgen.restoreSourceCursor(saved_cursor); |
| 3566 | 3572 | for (rl_components, full.ast.variables) |*variable_rl, variable_node| { |
| 3567 | 3573 | if (variable_rl.* != .typed_ptr) continue; |
| 3568 | 3574 | switch (tree.nodeTag(variable_node)) { |
| ... | ... | @@ -3896,7 +3902,9 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node. |
| 3896 | 3902 | return astgen.failNode(len_node, "unable to infer array size", .{}); |
| 3897 | 3903 | } |
| 3898 | 3904 | const len = try reachableExprComptime(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, len_node, node, .array_length); |
| 3905 | const saved_cursor = astgen.saveSourceCursor(); |
| 3899 | 3906 | const elem_type = try typeExpr(gz, scope, extra.elem_type); |
| 3907 | astgen.restoreSourceCursor(saved_cursor); |
| 3900 | 3908 | const sentinel = try reachableExprComptime(gz, scope, .{ .rl = .{ .coerced_ty = elem_type } }, extra.sentinel, node, .array_sentinel); |
| 3901 | 3909 | |
| 3902 | 3910 | const result = try gz.addPlNode(.array_type_sentinel, node, Zir.Inst.ArrayTypeSentinel{ |