Skip to content

for r in s over a str passes check and fails MIR lowering (NK_FOR) #1828

Closed

Description

@ehartford

for over a str type-checks and then fails MIR lowering — Sema accepts what MIR cannot lower (found building the #1819 matrix).

fn main:
    let s = "ab" ++ "cd"
    for r in s:
        print(f"{r}")

with check: ok. with run:

error: MIR lowering failed for function 'main' in strfor.w; AST codegen was removed, so this function cannot be compiled

WITH_MIR_AUDIT=1 names the node: [mir-lower-fail] kind=37 fn=main (NK_FOR).

The spec (docs/spec/strings.md, iteration.md) defines no iteration over str. Expected: Sema refuses the loop with a diagnostic (or, if Eric rules iteration over a str in, MIR lowers it) — post-Sema invalid MIR is a compiler bug either way (D65).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions