| ... | @@ -7468,7 +7468,7 @@ fn localVarRef( | ... | @@ -7468,7 +7468,7 @@ fn localVarRef( |
| 7468 | } | 7468 | } |
| 7469 | | 7469 | |
| 7470 | // Can't close over a runtime variable | 7470 | // Can't close over a runtime variable |
| 7471 | if (num_namespaces_out != 0 and !local_ptr.maybe_comptime) { | 7471 | if (num_namespaces_out != 0 and !local_ptr.maybe_comptime and !gz.is_typeof) { |
| 7472 | const ident_name = try astgen.identifierTokenString(ident_token); | 7472 | const ident_name = try astgen.identifierTokenString(ident_token); |
| 7473 | return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{ | 7473 | return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{ |
| 7474 | try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}), | 7474 | try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}), |
| ... | @@ -8041,6 +8041,7 @@ fn typeOf( | ... | @@ -8041,6 +8041,7 @@ fn typeOf( |
| 8041 | | 8041 | |
| 8042 | var typeof_scope = gz.makeSubBlock(scope); | 8042 | var typeof_scope = gz.makeSubBlock(scope); |
| 8043 | typeof_scope.is_comptime = false; | 8043 | typeof_scope.is_comptime = false; |
| | 8044 | typeof_scope.is_typeof = true; |
| 8044 | typeof_scope.c_import = false; | 8045 | typeof_scope.c_import = false; |
| 8045 | defer typeof_scope.unstack(); | 8046 | defer typeof_scope.unstack(); |
| 8046 | | 8047 | |
| ... | @@ -10882,6 +10883,9 @@ const GenZir = struct { | ... | @@ -10882,6 +10883,9 @@ const GenZir = struct { |
| 10882 | /// whenever we know Sema will analyze the current block with `is_comptime`, | 10883 | /// whenever we know Sema will analyze the current block with `is_comptime`, |
| 10883 | /// for instance when we're within a `struct_decl` or a `block_comptime`. | 10884 | /// for instance when we're within a `struct_decl` or a `block_comptime`. |
| 10884 | is_comptime: bool, | 10885 | is_comptime: bool, |
| | 10886 | /// Whether we're in an expression within a `@TypeOf` operand. In this case, closure of runtime |
| | 10887 | /// variables is permitted where it is usually not. |
| | 10888 | is_typeof: bool = false, |
| 10885 | /// This is set to true for inline loops; false otherwise. | 10889 | /// This is set to true for inline loops; false otherwise. |
| 10886 | is_inline: bool = false, | 10890 | is_inline: bool = false, |
| 10887 | c_import: bool = false, | 10891 | c_import: bool = false, |
| ... | @@ -10953,6 +10957,7 @@ const GenZir = struct { | ... | @@ -10953,6 +10957,7 @@ const GenZir = struct { |
| 10953 | fn makeSubBlock(gz: *GenZir, scope: *Scope) GenZir { | 10957 | fn makeSubBlock(gz: *GenZir, scope: *Scope) GenZir { |
| 10954 | return .{ | 10958 | return .{ |
| 10955 | .is_comptime = gz.is_comptime, | 10959 | .is_comptime = gz.is_comptime, |
| | 10960 | .is_typeof = gz.is_typeof, |
| 10956 | .c_import = gz.c_import, | 10961 | .c_import = gz.c_import, |
| 10957 | .decl_node_index = gz.decl_node_index, | 10962 | .decl_node_index = gz.decl_node_index, |
| 10958 | .decl_line = gz.decl_line, | 10963 | .decl_line = gz.decl_line, |