Skip to content

#1856 (§4.2.1): soft numeric literals settle at the demanding use - #2396

Merged
ehartford merged 2 commits into
mainfrom
sema-soft-literal-settles
Oct 13, 2026
Merged

ehartford merged 2 commits into
mainfrom
sema-soft-literal-settles

Conversation

@ehartford

@ehartford ehartford commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

§4.2.1 soft-literal settling for generic enum bindings (#1856), ported from the abandoned next-sema-values worktree onto current main's pending-generic machinery.

A variant call whose payload fixes a type parameter only through an unsuffixed numeric literal — let d = Ok(1), let o = Some(2) — registers as a pending generic binding, like List.new() and a bare None (#2103). The demanding use settles it:

  • wide(a) settles a = Ok(1) at Result[i64, str]; small(o) at Option[u8]; a typed binding at its annotation.
  • Each soft literal is rechecked at the settling type, so Ok(300) settled at u8 errors at the literal; suffixed literals stay hard.
  • Uses made before settlement (including {d:?} formatting) are retyped at settlement; D61 formatter registration for those uses defers to settlement, since the pre-settle type is a generic template no formatter can be built for.
  • A binding no use settles completes at its literals' default types (isize/f64) at scope exit when every parameter is fixed by a payload; otherwise the existing cannot-infer diagnostic stands.

Fixes

Ceremony

move-arg in src 847 -> 851, granted in build/ceremony-allowances.tsv: the three pending-soft-use lists join the FnBodyEnv scope snapshot beside the pending-generic maps, spelling the same env ownership transfer as every neighboring field.

Evidence (iterate tier)

Eric Hartford added 2 commits October 13, 2026 11:53
From the next-sema-values worktree's uncommitted work: a generic
enum parameter only unsuffixed literals fix is soft — the use that
settles the binding decides it, range-checked at the literal; a
suffixed literal is hard. behav + soft-out-of-range fail on main
(suffixed-hard already passes); implementation follows, re-expressed
on the current pending design. Also tracks the {d:?} type-0 ICE
(#2395) the behavior fixture's first lines hit today.
…se (#1856)

A variant call whose payload fixes a type parameter only through an unsuffixed numeric literal (Ok(1), Some(2)) now registers as a pending generic binding, like List.new() and a bare None. Settlement rechecks each soft literal at the settling type (out-of-range errors at the literal), requires hard payloads to agree, and retypes uses recorded before settlement; formatting uses defer D61 formatter registration to settlement, since the pre-settle type is a generic template. A binding no use settles completes at its literals' default types at scope exit; one with a parameter nothing fixes keeps the cannot-infer diagnostic. Suffixed literals stay hard.

Fixes #2395: formatting an unsettled Ok(1) binding reached MIR with type 0; it is now the cannot-infer error. Ceremony: move-arg src 847 -> 851 granted in build/ceremony-allowances.tsv (the three pending-soft-use lists join the FnBodyEnv snapshot's existing move-out pattern).
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN at 1b44864 (seed-driven, one battery for the stack):

  • gate rc=0 wall=125s (battery's own gate phase; the standalone pre-battery gate also passed, 352s)
  • uat rc=0 wall=28s
  • battery-checks rc=0 wall=1773s
  • verdict.w: rc=0 green; status.txt: GREEN / BATTERY_DONE

Marking ready and merging.

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.

1 participant