Skip to content

stage2: continue behaves incorrectly when nested in a conditional in an inline for #12171

Description

@topolarity

Zig Version

0.10.0-dev.3028+5e4f27af9

Steps to Reproduce

const std = @import("std");

test {
    var x: u32 = 1;
    inline for ([_]u8{1, 2, 3}) |_| {
        if (1 == 1) {
            x = 0;
            continue;
        }
    }
    std.debug.assert(x == 0);
}

Appears to be related to a bug encountered in #12111

Expected Behavior

Test should pass.

Actual Behavior

Test fails. It produces this AIR:

# Begin Function AIR: test.main:
  ...

  %0 = alloc(*u32)
  %2!= store(%0, %1!)
  %44 = load(u32, %0!)
  %47 = cmp_eq(%44!, %46!)
  %48!= call(%43!, [%47!])
  %49!= ret(@Zir.Inst.Ref.void_value)
# End Function AIR: test.main

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions