mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 09:33:18 +00:00
fix null literal outside function
This commit is contained in:
parent
404defd99b
commit
aed96e3512
@ -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);
|
||||
}
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user