Commit ae61e26680
Changed files (2)
src
test
cases
src/codegen.cpp
@@ -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;
}
{
test/cases/null.zig
@@ -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);
+}