fix null literal outside function

This commit is contained in:
Andrew Kelley 2016-05-08 00:15:05 -07:00
parent 404defd99b
commit aed96e3512
2 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -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,
};