| ... | ... | @@ -1513,6 +1513,7 @@ fn resolveDefinedValue( |
| 1513 | 1513 | ) CompileError!?Value { |
| 1514 | 1514 | if (try sema.resolveMaybeUndefVal(block, src, air_ref)) |val| { |
| 1515 | 1515 | if (val.isUndef()) { |
| 1516 | if (block.is_typeof) return null; |
| 1516 | 1517 | return sema.failWithUseOfUndef(block, src); |
| 1517 | 1518 | } |
| 1518 | 1519 | return val; |
| ... | ... | @@ -12268,6 +12269,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 12268 | 12269 | .inlining = block.inlining, |
| 12269 | 12270 | .is_comptime = false, |
| 12270 | 12271 | .is_typeof = true, |
| 12272 | .want_safety = false, |
| 12271 | 12273 | }; |
| 12272 | 12274 | defer child_block.instructions.deinit(sema.gpa); |
| 12273 | 12275 | |
| ... | ... | @@ -20832,7 +20834,7 @@ fn analyzeDeclVal( |
| 20832 | 20834 | const decl_ref = try sema.analyzeDeclRef(decl_index); |
| 20833 | 20835 | const result = try sema.analyzeLoad(block, src, decl_ref, src); |
| 20834 | 20836 | if (Air.refToIndex(result)) |index| { |
| 20835 | | if (sema.air_instructions.items(.tag)[index] == .constant) { |
| 20837 | if (sema.air_instructions.items(.tag)[index] == .constant and !block.is_typeof) { |
| 20836 | 20838 | try sema.decl_val_table.put(sema.gpa, decl_index, result); |
| 20837 | 20839 | } |
| 20838 | 20840 | } |
| ... | ... | @@ -20963,6 +20965,9 @@ fn analyzeLoad( |
| 20963 | 20965 | if (try sema.pointerDeref(block, ptr_src, ptr_val, ptr_ty)) |elem_val| { |
| 20964 | 20966 | return sema.addConstant(elem_ty, elem_val); |
| 20965 | 20967 | } |
| 20968 | if (block.is_typeof) { |
| 20969 | return sema.addConstUndef(elem_ty); |
| 20970 | } |
| 20966 | 20971 | } |
| 20967 | 20972 | |
| 20968 | 20973 | const valid_rt = try sema.validateRunTimeType(block, src, elem_ty, false); |