| author | |
| committer | |
| log | 175893913defb637fd14ea5d2b49bbdf79a3222d |
| tree | c139984de1cac470b270266b0a87b0b2ca5049db |
| parent | 9b91c76088e784bb622008623059eca5bbcd8700 |
See #5472 files changed, 7 insertions(+), 0 deletions(-)
src/codegen.cpp+1| ... | @@ -4554,6 +4554,7 @@ static void define_builtin_types(CodeGen *g) { | ... | @@ -4554,6 +4554,7 @@ static void define_builtin_types(CodeGen *g) { |
| 4554 | { | 4554 | { |
| 4555 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefLit); | 4555 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefLit); |
| 4556 | buf_init_from_str(&entry->name, "(undefined)"); | 4556 | buf_init_from_str(&entry->name, "(undefined)"); |
| 4557 | entry->zero_bits = true; | ||
| 4557 | g->builtin_types.entry_undef = entry; | 4558 | g->builtin_types.entry_undef = entry; |
| 4558 | } | 4559 | } |
| 4559 | { | 4560 | { |
test/cases/undefined.zig+6| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const assert = @import("std").debug.assert; | 1 | const assert = @import("std").debug.assert; |
| 2 | const mem = @import("std").mem; | ||
| 2 | 3 | ||
| 3 | fn initStaticArray() -> [10]i32 { | 4 | fn initStaticArray() -> [10]i32 { |
| 4 | var array: [10]i32 = undefined; | 5 | var array: [10]i32 = undefined; |
| ... | @@ -60,3 +61,8 @@ test "assign undefined to struct with method" { | ... | @@ -60,3 +61,8 @@ test "assign undefined to struct with method" { |
| 60 | assert(foo.x == 3); | 61 | assert(foo.x == 3); |
| 61 | } | 62 | } |
| 62 | } | 63 | } |
| 64 | |||
| 65 | test "type name of undefined" { | ||
| 66 | const x = undefined; | ||
| 67 | assert(mem.eql(u8, @typeName(@typeOf(x)), "(undefined)")); | ||
| 68 | } |