Skip to content

Codegen: a Vec element read (view) passed to str.slice is a ptr where i64 is expected; with check says ok #2023

Closed

Description

@ehartford

Spec: §3.8 / D22 ruling / D27 — xs[i] denotes the element place; a &T materializes T once an owned-value demand is established (an i64 parameter is such a demand).

Minimal repro (new darwin seed nightly-20261003-local-1-c884c1c2a17c and its stage1, main c884c1c):

var ss: Vec[i64] = Vec.new()
ss.push(1)
let s = ss[0]
print("ab".slice(0, s))

Expected: prints a. Actual: with check says ok; with run fails error: wrong argument type actual=ptr expected=i64 fn=main / error: code generation failed. analyze … audit:all (fn-main form): violation: code generation failed during integrated analysis and no earlier violation, so no Sema/MIR audit names the disagreement (a silent tool, per CLAUDE.md).

Matrix:

  • let s = ss[0] then "ab".slice(0, s) — FAIL (both slice args; Vec[i32] too)
  • "ab".slice(0, ss[0]) — FAIL
  • let s: i64 = ss[0] then "ab".slice(0, s) — ok
  • let s = ss[0] then a user fn take(a: i64) call take(s) — ok

So the builtin str.slice call path does not materialize the element view into its i64 parameters; a user fn call does.

Also: with analyze refuses an implicit-main file (expected declaration at the first top-level statement).

Workaround in tree: tools/wrap_diag_spans.w splice helper (a user fn with i64 params), whose comment wrongly blamed a frozen seed (#755 class). Remove the helper when this is fixed.

Activity

  1. added a commit that references this issue on Oct 3, 2026
  2. added 2 commits that reference this issue on Oct 3, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions