You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using commit abe7305, saw it also on commit from mid Feb.
Happens compiling the following code with zig build-exe:
conststd=@import("std");
pubconstFrameResponse=enum {
Running,
Finished,
CreateCancelled,
};
constSomething=enum {
AA,
BB,
};
pubfnhandleFrame(dT: f32, st: Something) !FrameResponse {
if (dT==0) returnerror.BadTime;
constrv=switch (st) {
.AA=>FrameResponse.Running,
.BB=>blk: {
if (true) break :blk.Running; // NOTE: Qualifying the enum here makes the compile succeed.break :blk.Finished;
},
};
returnrv;
}
pubfnmain() !void {
_=tryhandleFrame(1, .AA);
}
Qualifying line .Running on line #19 makes the compile succeed. Small changes like removing the error union from the handleFrame function, or removing the enum type qualification from line #17 makes the compile not crash, giving a compile error instead: error: cannot store runtime value in type '(enum literal)'
The stack from the compile:
Segmentation fault at address 0x8
/home/pkelley/src/zig/src/buffer.cpp:68:5: 0x857300 in buf_hash (/home/pkelley/src/zig/src/buffer.cpp)
assert(buf->list.length);
^
/home/pkelley/src/zig/src/hash_map.hpp:238:22: 0x8470e3 in key_to_index (/home/pkelley/src/zig/src/analyze.cpp)
return (int)(HashFunction(key) % ((uint32_t)_capacity));
^
/home/pkelley/src/zig/src/hash_map.hpp:223:27: 0x846f13 in internal_get (/home/pkelley/src/zig/src/analyze.cpp)
int start_index = key_to_index(key);
^
/home/pkelley/src/zig/src/hash_map.hpp:81:16: 0x84510c in maybe_get (/home/pkelley/src/zig/src/analyze.cpp)
return internal_get(key);
^
/home/pkelley/src/zig/src/analyze.cpp:4299:61: 0x82b520 in find_enum_type_field (/home/pkelley/src/zig/src/analyze.cpp)
auto entry = enum_type->data.enumeration.fields_by_name.maybe_get(name);
^
/home/pkelley/src/zig/src/ir.cpp:12076:36: 0x899786 in ir_resolve_peer_types (/home/pkelley/src/zig/src/ir.cpp)
TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value->data.x_enum_literal);
^
/home/pkelley/src/zig/src/ir.cpp:20218:42: 0x8c7bd0 in ir_analyze_instruction_phi (/home/pkelley/src/zig/src/ir.cpp)
peer_parent->resolved_type = ir_resolve_peer_types(ira,
^
/home/pkelley/src/zig/src/ir.cpp:29270:20: 0x89753d in ir_analyze_instruction_base (/home/pkelley/src/zig/src/ir.cpp)
return ir_analyze_instruction_phi(ira, (IrInstSrcPhi *)instruction);
^
/home/pkelley/src/zig/src/ir.cpp:29572:38: 0x896846 in ir_analyze (/home/pkelley/src/zig/src/ir.cpp)
IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
^
/home/pkelley/src/zig/src/analyze.cpp:4810:34: 0x83ca9a in analyze_fn_ir (/home/pkelley/src/zig/src/analyze.cpp)
ZigType *block_return_type = ir_analyze(g, fn->ir_executable,
^
/home/pkelley/src/zig/src/analyze.cpp:4926:5: 0x82c5eb in analyze_fn_body (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_ir(g, fn_table_entry, return_type_node);
^
/home/pkelley/src/zig/src/analyze.cpp:4578:13: 0x82c2a9 in resolve_inferred_error_set (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_body(g, infer_fn);
^
/home/pkelley/src/zig/src/ir.cpp:26740:18: 0x8d3e67 in ir_analyze_instruction_test_err (/home/pkelley/src/zig/src/ir.cpp)
if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.base.source_node)) {
^
/home/pkelley/src/zig/src/ir.cpp:29386:20: 0x897ae7 in ir_analyze_instruction_base (/home/pkelley/src/zig/src/ir.cpp)
return ir_analyze_instruction_test_err(ira, (IrInstSrcTestErr *)instruction);
^
/home/pkelley/src/zig/src/ir.cpp:29572:38: 0x896846 in ir_analyze (/home/pkelley/src/zig/src/ir.cpp)
IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
^
/home/pkelley/src/zig/src/analyze.cpp:4810:34: 0x83ca9a in analyze_fn_ir (/home/pkelley/src/zig/src/analyze.cpp)
ZigType *block_return_type = ir_analyze(g, fn->ir_executable,
^
/home/pkelley/src/zig/src/analyze.cpp:4926:5: 0x82c5eb in analyze_fn_body (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_ir(g, fn_table_entry, return_type_node);
^
/home/pkelley/src/zig/src/analyze.cpp:4578:13: 0x82c2a9 in resolve_inferred_error_set (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_body(g, infer_fn);
^
/home/pkelley/src/zig/src/ir.cpp:26740:18: 0x8d3e67 in ir_analyze_instruction_test_err (/home/pkelley/src/zig/src/ir.cpp)
if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.base.source_node)) {
^
/home/pkelley/src/zig/src/ir.cpp:29386:20: 0x897ae7 in ir_analyze_instruction_base (/home/pkelley/src/zig/src/ir.cpp)
return ir_analyze_instruction_test_err(ira, (IrInstSrcTestErr *)instruction);
^
/home/pkelley/src/zig/src/ir.cpp:29572:38: 0x896846 in ir_analyze (/home/pkelley/src/zig/src/ir.cpp)
IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
^
/home/pkelley/src/zig/src/analyze.cpp:4810:34: 0x83ca9a in analyze_fn_ir (/home/pkelley/src/zig/src/analyze.cpp)
ZigType *block_return_type = ir_analyze(g, fn->ir_executable,
^
/home/pkelley/src/zig/src/analyze.cpp:4926:5: 0x82c5eb in analyze_fn_body (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_ir(g, fn_table_entry, return_type_node);
^
/home/pkelley/src/zig/src/analyze.cpp:5038:13: 0x82d590 in semantic_analyze (/home/pkelley/src/zig/src/analyze.cpp)
analyze_fn_body(g, fn_entry);
^
/home/pkelley/src/zig/src/codegen.cpp:9441:9: 0x861b73 in gen_root_source (/home/pkelley/src/zig/src/codegen.cpp)
semantic_analyze(g);
^
/home/pkelley/src/zig/src/codegen.cpp:10504:13: 0x860473 in codegen_build_and_link (/home/pkelley/src/zig/src/codegen.cpp)
gen_root_source(g);
^
/home/pkelley/src/zig/src/main.cpp:1256:17: 0x81e32b in main0 (/home/pkelley/src/zig/src/main.cpp)
codegen_build_and_link(g);
^
/home/pkelley/src/zig/src/main.cpp:1406:19: 0x8193c3 in main (/home/pkelley/src/zig/src/main.cpp)
auto result = main0(argc, argv);
^
The text was updated successfully, but these errors were encountered:
andrewrk
added
bug
Observed behavior contradicts documented or intended behavior
stage1
The process of building from source via WebAssembly and the C backend.
labels
Mar 8, 2020
Using commit abe7305, saw it also on commit from mid Feb.
Happens compiling the following code with
zig build-exe
:Qualifying line .Running on line #19 makes the compile succeed. Small changes like removing the error union from the
handleFrame
function, or removing the enum type qualification from line #17 makes the compile not crash, giving a compile error instead:error: cannot store runtime value in type '(enum literal)'
The stack from the compile:
The text was updated successfully, but these errors were encountered: