parent
707131e37b
commit
e66ed0f2e2
|
@ -3391,12 +3391,15 @@ static TypeTableEntry *analyze_null_literal_expr(CodeGen *g, ImportTableEntry *i
|
|||
assert(node->type == NodeTypeNullLiteral);
|
||||
|
||||
if (!expected_type) {
|
||||
add_node_error(g, node,
|
||||
buf_sprintf("unable to determine null type"));
|
||||
add_node_error(g, node, buf_sprintf("unable to determine null type"));
|
||||
return g->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
assert(expected_type->id == TypeTableEntryIdMaybe);
|
||||
if (expected_type->id != TypeTableEntryIdMaybe) {
|
||||
add_node_error(g, node,
|
||||
buf_sprintf("expected maybe type, got '%s'", buf_ptr(&expected_type->name)));
|
||||
return g->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
node->data.null_literal.resolved_struct_val_expr.type_entry = expected_type;
|
||||
node->data.null_literal.resolved_struct_val_expr.source_node = node;
|
||||
|
|
|
@ -1810,6 +1810,10 @@ fn derp(){}
|
|||
)SOURCE", 2,
|
||||
".tmp_source.zig:3:12: error: no label in scope named 'label'",
|
||||
".tmp_source.zig:5:1: error: label 'label' defined but not used");
|
||||
|
||||
add_compile_fail_case("assign null to non-nullable pointer", R"SOURCE(
|
||||
const a: &u8 = null;
|
||||
)SOURCE", 1, ".tmp_source.zig:2:16: error: expected maybe type, got '&u8'");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue
Block a user