fix compiler segfault on null ?? x

closes #390
This commit is contained in:
Andrew Kelley 2017-06-14 19:32:52 -04:00
parent 7f0620a20f
commit ae61e26680
2 changed files with 6 additions and 0 deletions

View File

@ -4224,6 +4224,7 @@ static void define_builtin_types(CodeGen *g) {
{
TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNullLit);
buf_init_from_str(&entry->name, "(null)");
entry->zero_bits = true;
g->builtin_types.entry_null = entry;
}
{

View File

@ -143,3 +143,8 @@ test "unwrap nullable which is field of global var" {
unreachable;
}
}
test "null with default unwrap" {
const x: i32 = null ?? 1;
assert(x == 1);
}