-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig Version
0.11.0-dev.337+609716524
Steps to Reproduce and Observed Behavior
// test.zig
comptime {
const m_name: ?[1]u8 = "a".*;
if (m_name) |*name| {
_ = @Type(.{ .Struct = .{
.layout = .Auto,
.fields = &.{.{
.name = name,
.field_type = u8,
.default_value = null,
.is_comptime = false,
.alignment = 1,
}},
.decls = &.{},
.is_tuple = false,
} });
}
}$ zig test test.zig
thread 10851 panic: reached unreachable code
Analyzing test.zig: test.zig:comptime_0
%13 = optional_payload_unsafe_ptr(%9) node_offset:3:25 to :3:26
%14 = field_type(@Zir.Inst.Ref.type_info_type, Struct) node_offset:4:32 to :4:34
%15 = field_type(%14, layout) node_offset:5:23 to :5:28
%16 = enum_literal("Auto") token_offset:5:24 to :5:28
%17 = as_node(%15, %16) node_offset:5:23 to :5:28
%18 = field_type(%14, fields) node_offset:6:23 to :6:24
%19 = struct_init_anon([name=%13], [field_type=@Zir.Inst.Ref.u8_type], [default_value=@Zir.Inst.Ref.null_value], [is_comptime=@Zir.Inst.Ref.bool_false], [alignment=@Zir.Inst.Ref.one]) node_offset:6:26 to :6:28
%20 = array_init_anon_ref({%19}) node_offset:6:24 to :6:26
%21 = as_node(%18, %20) node_offset:6:23 to :6:24
%22 = field_type(%14, decls) node_offset:13:22 to :13:26
%23 = ref(@Zir.Inst.Ref.empty_struct) token_offset:13:23 to :13:24
%24 = as_node(%22, %23) node_offset:13:22 to :13:26
%25 = field_type(%14, is_tuple) node_offset:14:25 to :14:30
%26 = as_node(%25, @Zir.Inst.Ref.bool_false) node_offset:14:25 to :14:30
%27 = struct_init_anon([layout=%17], [fields=%21], [decls=%24], [is_tuple=%26]) node_offset:4:32 to :4:34
%28 = as_node(%14, %27) node_offset:4:32 to :4:34
%29 = struct_init_anon([Struct=%28]) node_offset:4:19 to :4:21
> %30 = extended(reify(%29)) node_offset:4:13 to :4:18
%31 = ensure_result_non_error(%30) node_offset:4:13 to :4:18
%32 = break_inline(%12, @Zir.Inst.Ref.void_value)
For full context, use the command
zig ast-check -t test.zig
in test.zig: test.zig:comptime_0
> %11 = condbr_inline(%10, {%13..%32}, {%33}) node_offset:3:5 to :3:7
in test.zig: test.zig:comptime_0
> %12 = block_inline({%10, %11}) node_offset:3:5 to :3:7
zig/src/value.zig:2908:21: 0x8e2735 in elemValueAdvanced (zig)
else => unreachable,
^
zig/src/value.zig:2836:33: 0x73eac0 in elemValueBuffer (zig)
return elemValueAdvanced(val, mod, index, null, buffer) catch unreachable;
^
zig/src/value.zig:896:49: 0x73e906 in arrayToAllocatedBytes (zig)
const elem_val = val.elemValueBuffer(mod, i, &elem_value_buf);
^
zig/src/value.zig:886:80: 0x73dce1 in toAllocatedBytes (zig)
return arrayToAllocatedBytes(slice.ptr, slice.len.toUnsignedInt(target), allocator, mod);
^
zig/src/Sema.zig:18624:25: 0xe843c9 in reifyStruct (zig)
Type.initTag(.const_slice_u8),
^
zig/src/Sema.zig:18134:130: 0xaf484f in zirReify (zig)
return try sema.reifyStruct(block, inst, src, layout, backing_int_val, fields_val, name_strategy, is_tuple_val.toBool());
^
zig/src/Sema.zig:1147:64: 0x8b418a in analyzeBodyInner (zig)
.reify => try sema.zirReify( block, extended, inst),
^
zig/src/Sema.zig:815:45: 0x743db5 in analyzeBodyBreak (zig)
const break_inst = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
^
zig/src/Sema.zig:1594:62: 0x8ba6b5 in analyzeBodyInner (zig)
const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse
^
zig/src/Sema.zig:815:45: 0x743db5 in analyzeBodyBreak (zig)
const break_inst = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
^
zig/src/Sema.zig:1504:55: 0x8b8c69 in analyzeBodyInner (zig)
break :b try sema.analyzeBodyBreak(&child_block, inline_body);
^
zig/src/Sema.zig:815:45: 0x743db5 in analyzeBodyBreak (zig)
const break_inst = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
^
zig/src/Module.zig:4634:50: 0x7400d6 in semaDecl (zig)
const result_ref = (try sema.analyzeBodyBreak(&block_scope, body)).?.operand;
^
zig/src/Module.zig:4255:38: 0x632e08 in ensureDeclAnalyzed (zig)
const type_changed = mod.semaDecl(decl_index) catch |err| switch (err) {
^
zig/src/Compilation.zig:3217:38: 0x7230ce in processOneJob (zig)
module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {
^
zig/src/Compilation.zig:3087:30: 0x6747ae in performAllTheWork (zig)
try processOneJob(comp, work_item);
^
zig/src/Compilation.zig:2396:31: 0x6706d0 in update (zig)
try comp.performAllTheWork(main_progress_node);
^
zig/src/main.zig:3354:20: 0x69cd96 in updateModule (zig)
try comp.update();
^
zig/src/main.zig:3021:17: 0x592cca in buildOutputType (zig)
updateModule(gpa, comp, hook) catch |err| switch (err) {
^
zig/src/main.zig:236:31: 0x56d575 in mainArgs (zig)
return buildOutputType(gpa, arena, args, .zig_test);
^
zig/src/main.zig:174:20: 0x56c9d0 in main (zig)
return mainArgs(gpa, arena, args);
^
zig/lib/std/start.zig:614:37: 0x56ef51 in main (zig)
const result = root.main() catch |err| {
^
Expected Behavior
Compiles and works
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.