fix crash when var init has compile error
and then the var is referenced closes #1483
This commit is contained in:
parent
7505529e44
commit
b18af37c57
|
@ -13107,8 +13107,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
|
|||
assert(ira->codegen->errors.length != 0);
|
||||
return ira->codegen->invalid_instruction;
|
||||
}
|
||||
assert(var->value->type);
|
||||
if (type_is_invalid(var->value->type))
|
||||
if (var->value->type == nullptr || type_is_invalid(var->value->type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
bool comptime_var_mem = ir_get_var_is_comptime(var);
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"variable initialization compile error then referenced",
|
||||
\\fn Undeclared() type {
|
||||
\\ return T;
|
||||
\\}
|
||||
\\fn Gen() type {
|
||||
\\ const X = Undeclared();
|
||||
\\ return struct {
|
||||
\\ x: X,
|
||||
\\ };
|
||||
\\}
|
||||
\\export fn entry() void {
|
||||
\\ const S = Gen();
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:12: error: use of undeclared identifier 'T'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"refer to the type of a generic function",
|
||||
\\export fn entry() void {
|
||||
|
|
Loading…
Reference in New Issue
Block a user