Skip to content

compiler panics when branching break on comptime #11424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leesongun opened this issue Apr 13, 2022 · 2 comments
Closed

compiler panics when branching break on comptime #11424

leesongun opened this issue Apr 13, 2022 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@leesongun
Copy link
Contributor

leesongun commented Apr 13, 2022

Zig Version

0.10.0-dev.1741+d2681d253

Steps to Reproduce

export const a = init: {
    if (true)
        break :init true;
    break :init true;
};

godbolt

checked locally with zig 0.10.0-dev.1741+d2681d253, reproduced with godbolt.

Expected Behavior

the program compiles

Actual Behavior

when analyzing <source>:1:23 in compiler source at /workspace/src/stage1/ir.cpp:5626: thread 1 panic: assertion failed. This is a bug in the Zig compiler.

which is

static void ir_start_bb(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, Stage1ZirBasicBlock *const_predecessor_bb) {
    src_assert(!old_bb->suspended,
            (old_bb->instruction_list.length != 0) ?
            old_bb->instruction_list.at(0)->source_node : nullptr);
@leesongun leesongun added the bug Observed behavior contradicts documented or intended behavior label Apr 13, 2022
@leesongun leesongun changed the title compiler panics on branching init of comptime constant compiler panics when branching break on comptime Apr 13, 2022
@jibal
Copy link

jibal commented Apr 14, 2022

Why closed? I've encountered this panic. (Unfortunately I didn't note the code that caused it, but worked around it ... I hit several compiler bugs / day and have become sloppy about recording them.)

@leesongun
Copy link
Contributor Author

duplicate of #7386?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants