Skip to content

Vec[str] element view passed unmarshalled to str parameter — invalid LLVM IR #755

Closed

Description

@ehartford

Repro (HEAD daf9fc5, also on seed v0.15.1-g21751b3be)

fn main:
    var files: Vec[str] = Vec.new()
    files.push("hello")
    let out = "hheelloo".replace(files.get(0), "")
    print(out)

with check: ok (both seed and fresh stage2).
with run / build: LLVM function verification failed after MIR cleanup for main → code generation failed.

Root cause direction

The invalid instruction:

%4 = call ptr @with_vec_get_ptr(ptr %1, i64 0)
%5 = call %str @with_str_replace(%str %.fca.1.insert37, ptr %4, %str %.fca.1.insert45)

files.get(0) is a D27 element view (&str = place pointer). Passing it to replace(pat: str) is an owned-value demand, so per D22 the view must materialize an independent str — Sema accepts exactly that, but the call-arg lowering passes the raw place pointer where the declared ABI wants the %str fat value by caller/callee divergence. Per D6 this is a FnAbi/PassMode question: the materializing load for a view-typed argument against an owned PassMode::Direct param is missing in push_call_arg (or the demand never reaches it).

Impact

Any vec.get(i) result passed directly to a str-consuming builtin miscompiles. This blocked with -e migration one-liners during #747 tooling work (forced ed fallbacks). Same class will get heavy exercise when #747 flips str to owned, so it should land before or with the flip.

Discovered while hunting the battery-7 UAF; unrelated to that fix (daf9fc5).

Activity

  1. added
    bug
    on Aug 2, 2026
  2. added a commit that references this issue on Aug 17, 2026
  3. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-08-31: CLOSE (overcome by events). The filed repro compiles AND runs clean with correct output on the current compiler — the check-ok/run-miscompile divergence closed with the D27/#747 view-materialization work.

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