Skip to content

Fix #2023: str intrinsic index args are owned i64 demands; MIR validator names an unmaterialized view; analyze/debug flags take implicit main - #2031

Merged
ehartford merged 5 commits into
seed-bumpfrom
fix-2023
Oct 3, 2026
Merged

ehartford merged 5 commits into
seed-bumpfrom
fix-2023

Conversation

@ehartford

@ehartford ehartford commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2020 (built with seed nightly-20261003-local-1-c884c1c2a17c).

  • Sema (SemaCheck.w, the TY_STR builtin-method branch): str.slice/byte_at/repeat index and count args go through check_builtin_method_call_arg, which records the D22/D27 Copy-view materialization; it also refuses a wrong type ("abc".slice("x", 2) was accepted).
  • MIR validator: a &T (T scalar) passed to an owned scalar parameter (str intrinsic index args, direct calls) is invalid MIR, named before codegen.
  • analyze and the check debug flags (--validate-all, --validate-ownership, --dump-drop-plan, ...) compile their file as the entry root, so implicit main works.
  • tools/wrap_diag_spans.w: splice helper inlined.

Fixtures: behav_2023_str_method_element_view_arg, err_2023_str_slice_arg_type, internals/mir_call_unmaterialized_view_test, deep-debug-tool-tests implicit-main entries.

src/main build :gate: survey all targets green (367.8s). :drop-audit: 254 cells, 0 regressions. Battery not run.

Closes #2023.

@ehartford
ehartford added this pull request to stack #2032 October 3, 2026 09:15
@ehartford ehartford changed the title fix 2023 Fix #2023: str intrinsic index args are owned i64 demands; MIR validator names an unmaterialized view; analyze/debug flags take implicit main Oct 3, 2026
Eric Hartford added 5 commits October 3, 2026 04:02
…alid MIR (#2023)

`"ab".slice(0, xs[0])` passed the element view `&i64` to with_str_slice_ref's
i64 end index; every validator said ok and codegen failed ("wrong argument
type actual=ptr expected=i64"). mir_validate_call_unmaterialized_view
checks a str intrinsic's index/count arguments and a direct call's scalar
parameters against its callee body. Under a stage1 without the Sema fix,
`analyze z.w audit:all` now reports:

    error: invalid MIR before codegen: call argument 2 is a Copy view (&T)
    where the callee parameter is the owned scalar T: the owned demand was
    not materialized (#2023)

test/internals/mir_call_unmaterialized_view_test.w pins both shapes and
their materialized controls.
…64 demands (#2023)

Line: SemaCheck.w check_method_call, the `resolved_tk == TypeKind.TY_STR`
branch returned builtin_intrinsic_method_return_type's type without looking
at any argument. A user fn's i64 parameter goes through
note_call_arg_coercion -> record_contextual_copy_adjustment, so MIR reads
the pointee (`copy _5.*`); str.slice's did not, so MIR passed the element
view (`copy _2`, a &i64) and codegen failed:
"wrong argument type actual=ptr expected=i64 fn=apply". It also accepted
`"abc".slice("x", 2)` (`check` said ok).

Fix: slice's two and byte_at's/repeat's one leading parameters
(with_str_slice_ref, with_str_byte_at_ref, with_str_repeat_ref: i64) go
through check_builtin_method_call_arg, which records the Copy-view
materialization (D22/D27) and refuses a wrong type.

Fixtures: behav_2023_str_method_element_view_arg (pre-fix stage1: codegen
failed in splice; now prints a / Xb / aXb / 98 / abab);
err_2023_str_slice_arg_type (pre-fix: ok; now refused).
…licit main works (#2023)

`with analyze z.w audit:all` on a file of top-level statements refused it
("expected declaration" at the first statement, then "analysis
compilation failed"), and so did `check --validate-all`,
`--validate-ownership`, `--dump-drop-plan`, `--trace-place` and the other
Compilation *_file debug entries: they called compile_file, which parses a
module, where `check` and `build` call compile_entry_file (§18.5b implicit
main). They now compile the root as an entry.

deep-debug-tool-tests gains an implicit-main fixture (the #2023 element view
into str.slice) under `analyze … audit:all` (violations=0 ok) and
`--validate-ownership` (ok); the pre-fix stage1 refused it in both.
The edit is the natural concat again. Under the fixed stage1, --apply over a
two-site assignment-mismatch diagnostics file writes output byte-identical
to the helper version's. A compiler older than this fix (the pinned seed,
the installed v0.15.3.0) still fails it in codegen.
@ehartford
ehartford marked this pull request as ready for review October 3, 2026 15:13
@ehartford
ehartford merged commit 1f2021a into main Oct 3, 2026
@ehartford
ehartford deleted the fix-2023 branch October 3, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant