mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
parent
688d02176c
commit
3607d9ee68
@ -17479,6 +17479,8 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
|
||||
field->decl_node = value ? value->source_node : suspend_source_instr->source_node;
|
||||
if (value && instr_is_comptime(value)) {
|
||||
ZigValue *val = ir_resolve_const(ira, value, UndefOk);
|
||||
if (!val)
|
||||
return ira->codegen->invalid_instruction;
|
||||
field->is_comptime = true;
|
||||
field->init_val = create_const_vals(1);
|
||||
copy_const_val(field->init_val, val);
|
||||
|
||||
@ -2,6 +2,18 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.addTest("error in struct initializer doesn't crash the compiler",
|
||||
\\pub export fn entry() void {
|
||||
\\ const bitfield = struct {
|
||||
\\ e: u8,
|
||||
\\ e: u8,
|
||||
\\ };
|
||||
\\ var a = .{@sizeOf(bitfield)};
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:4:9: error: duplicate struct field: 'e'",
|
||||
});
|
||||
|
||||
cases.addTest("repeated invalid field access to generic function returning type crashes compiler. #2655",
|
||||
\\pub fn A() type {
|
||||
\\ return Q;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user