diff --git a/src/analyze.cpp b/src/analyze.cpp index 4bc3022765..893da7fd5e 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3742,7 +3742,6 @@ static TypeTableEntry *analyze_null_literal_expr(CodeGen *g, ImportTableEntry *i node->data.null_literal.resolved_struct_val_expr.type_entry = expected_type; node->data.null_literal.resolved_struct_val_expr.source_node = node; - block_context->fn_entry->struct_val_expr_alloca_list.append(&node->data.null_literal.resolved_struct_val_expr); return resolve_expr_const_val_as_null(g, node, expected_type); } diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 6d8ccc9882..540d7eba2c 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -1612,3 +1612,14 @@ fn exact_division() { fn div_exact(a: u32, b: u32) -> u32 { @div_exact(a, b) } + +#attribute("test") +fn null_literal_outside_function() { + assert(here_is_a_null_literal.context == null); +} +struct SillyStruct { + context: ?i32, +} +const here_is_a_null_literal = SillyStruct { + .context = null, +};