Repository navigation
Conversation
added 14 commits
October 9, 2026 20:55
… isize, layout-field warning; literal-local use-typing prototype - isize/usize take the target's size width (wasm32: 32 bits); unsuffixed literals nothing demands a width of are isize, range-checked at that width. - len()/count()/position()/capacity()/find()/index_of() and enumerate's index are isize; the len intrinsics narrow the runtime's i64 header read at the one store; enumerate's index uses the adapter field's width. - A C-layout or serialized struct with an isize/usize field warns (c_import records excepted: they mirror C's size_t). - CImport's size estimate reads isize, pointer and c_long width from the target (c_long is 4 bytes on Windows and wasm32). - The narrowing diagnostic names the argument and callee. - Prototype, pending Eric's ruling: an unsuffixed integer literal's local binding takes its type from its uses via D93's demand machinery; D93's lookups are now maps (were quadratic scans).
…ping prototype is out Eric 2026-10-09: "Untyped constants: yes." Locals are not typed by use; each i32 a counter flows into is judged intentional or legacy. The 107 module-level `let NAME = <integer>` in src/ and rt/ become `const`, so each use types them. D93's literal-binding lookups stay maps.
…into ids and stored widths are i32 - The narrowing error points at the literal binding that made a name isize. - Widened (counts, indices, offsets into memory): with_arg_at, with_ci_child's child index, the with_cimport_* declaration/macro/param/field indices, ensure_fields_cached, remove_borrow_at, link_stage_read_u32_le, the UAT runner's line and step counts, ReceiverMigration.slice. - Kept i32 (ids, compact AST/IR storage, C ABI widths, masks): the literal bindings that flow into them are typed i32 (out/audit/annotate.w, driven by the labels). 2,508 -> 967 narrowing errors in the compiler.
…r peer's type; accessor indices, positions and range tables widen to isize; ids, flags and C widths stay i32
…if chose isize, also after its scope closed; count and position returns widen to isize, ids, flags, parsed values and source lines stay i32
…teral operand, so a field, peer or binding types its literals
… the number's type, not the isize default or a promotion
…i32; counts, indices and string positions widen
…umbers and comptime extra counts stay i32
… widen; symbols, MIR stmt and arg indices, bit widths and flags stay i32
…Ok is checked, tuple literal arms and borrowed literals take their peer's type, nested literal joins re-decide, isize/usize to_string
…s owned u32 words (D27), iter_sum's total is i32, dead returns after exit removed
…corded (TypeLayout.w changed only by an annotation, no convention change)
… u64 when it fits only unsigned), never through isize; the wasm32 pcre2, zlib and tommyds bundles build
added 9 commits
October 9, 2026 22:13
…or; D124: an untyped constant under a cast is found through its declaration, a float is classified, an unevaluable constant is reported, never typed isize
…rough llvm.fpto[su]i.sat, scalar and vector; compile-time casts convert the same way, integer casts keep the low bits; the unsafe fptosi builders are gone
…8 past 64), a shift that drops bits is not a 64-bit value; past 128 bits the error names the compiler's limit
…ze under the seed and the new compiler; positions widen, statuses, parsed values, timeouts and modes stay i32
… where a call checked its arguments first (generic calls and methods)
…, examples rule 2026-09-22; D126 records the follow-up rule that removes them) var sum: i32 = 0 in the program and its database test, and List[i32] on the four literal bindings passed to []i32 parameters in the program and the tally test. Under D114 an untyped local is isize and is not typed by its uses; Eric ruled (D126) that D114 lands with these annotations and that a narrow untyped-locals rule follows as its own decision and removes them.
…heck clean at isize; five more examples annotated for the spec change Tools: positions and indices widen (each tool's slice helper drops its i64 casts), counts and parsed values stay i32. std.task's race winner is an index (isize). Examples (spec change under the examples rule, as D126 ruled for c-interop): the async-auction bidder loop is 0i32..3, and untyped accumulators in the channels, json-parser, nebula and service tests are i32; the narrow untyped-locals rule (D126 follow-up) removes these.
…ing-parameter moves); the gen-push fixture's countdown receiver is i32
… takes its type (unwrap_or(0), ?? 0); literal arms checked before the join are retyped under an outer demand
…ast, and adapt as a block's tail
Three places where a literal still fell back to the isize default while
a context named its type (§4.2.1, §4.3c):
- A bracket literal at a `&` parameter (`total([1, 2, 3])` at
`xs: &List[i32]`, the §4.3c example) read the reference type as no
demand. The literal now reads the demand through one `&`.
- A generic call bound `T` from an untyped literal argument before the
typed arguments and the call's demand: `apply(2147483647, (x: i32) ->
i64 => x)` and `let (a, b): (i32, List[str]) = paired(5)` were refused.
Literal arguments now bind only parameters nothing else bound.
- A join arm whose literal is a block's tail (`Err(_) => { note(e); 0 }`)
was not a literal arm under rule 8. It is now; only the tail is checked
again, so the block's statements are checked once.
…MIR)
`if b: owned(2) else: ("n" ++ "o", 0)` joined `(str, i32)` and
`(str, isize)`: each type accepted the other, so the merge took the one
with the lower type id, and the other arm reached MIR unconverted
("use rvalue type is incompatible with assign destination"). An
aggregate's elements do not convert (#1368), so two tuple types that
differ are arms that disagree (§4.2.1 rule 8), reported with both types.
The fixture spells the literal element `0i32`. Typing a literal element
of a mixed tuple from the other arms is not what rule 8 says (it names a
tuple of untyped literals); that extension is left for its own ruling.
added 11 commits
October 10, 2026 05:01
Locals are not typed by their uses (D114 follow-up; the narrow reopen is D126's separate decision). Each fixture whose literal local, range or global fed an i32 parameter, return, field or extension method now says `: i32` (or `0i32..`, `List[i32]`, `42i32`). Where a test asserts what inference produces, it asserts the D114 answer instead: D43's tail inference binds `isize`, `let xs: List = [1, 2, 3]` is `List[isize]` (§4.3c rule 1), `[0, K.A, K.B]` beside a repr enum is `List[isize]`, duck_method_fail names `isize`, and issue113's extern declaration matches its untyped owner (`isize`), which must stay untyped (#2335).
…es the message Nine expectations quoted the type a literal defaulted to (`found 'i32'`, `Range[i32]`, `Pair[i32]`, "if arms have types i32 and str"); under D114 the default is isize and the same error names it. Three fixtures whose error needs an i32 local (an `extend i32` receiver, an `&i32` parameter) say `: i32`, so each still reaches the error it tests.
…meter The binds-last pass bound a literal only at a bare `T`, so `print(0)` (`v: &T`) left T unbound: "cannot infer type parameter 'T'". The pass reads through one `&`, as bind_type_params_from_type_expr does for an auto-referenced argument (§3.8). sema-order-check found it: two fixtures already failing for their own reason hid it in forward order and showed it in reverse.
`sm.get(h).unwrap() == Some(13)` typed `Some(13)` against `&Option[i32]`,
which names no payload, so the literal took the isize default and MIR
was asked for an Option[isize] -> Option[i32] cast ("unsupported cast
in MIR"). A comparison compares values; the constructor's peer is the
viewed type (§4.2.1 rule 3). `check` passed it, so the behavior sweep
missed it; the D acceptance corpus, which builds, found it.
…ations (D29 corpus)
…d, Debug; isize JSON) isize became the literal default with only Display and ToString, so a bound on any other trait refused the most common integer: `show(5)` at `T: Debug`, a BTreeMap literal's keys (Ord), `T: Default`. Both pointer-width types now carry i64's set. isize also serializes as JSON (lossless through i64) and deserializes with a range check, refusing a value a 32-bit isize cannot hold rather than truncating it; usize shares JSON's existing lack of unsigned integers.
…ments (§4.2.6) Two views accepted a numeric element of another width and read it in place, on main as well as under D114: - `head(wide[0..2])` with `wide: List[i64]` at `xs: []i32` (or `&wide[0..2]` at `&[i32]`) read the low half of each element: 5 + 7 printed 5. Slice elements now follow the rule a `&T` pointee already does (ref_numeric_pointees_differ). - `f(a)` with `a: i32` at `x: &i64` auto-referenced the four-byte place and read eight: -1 printed 4294967295. The auto-reference branch now requires the pointee's numeric type. D114 made both common (a literal list is a List[isize]); the behavior corpus caught them as wrong output, not as errors.
…differ do not compare - A literal argument checked before its generic method's or specialization's parameters were known (`7 in bag`, `b.contains(7)` at `value: &T`, T = i32) stayed isize and reached codegen as a value where a pointer was expected. retype_literal_call_arg gives it the parameter's value type at both sites, and an untyped literal under a `&N` demand is an N. - `Option[i32] < Option[isize]` was accepted and reached MIR as operands of incompatible types. Two instances of one generic type whose arguments differ do not compare, as two tuple types already do (#1996).
…order holds Found by building and running the whole behavior corpus (the earlier sweep only checked, and missed build-time and run-time failures): - Layout (#1368, §4.2.6). A generic instance's type arguments and a range's bounds are part of its layout. types_compatible (fast and slow paths) took `Box[isize]` for `Box[i32]` (an impl for one read the other's fields at the wrong offsets: 4 + 7 came back 4) and `Range[isize]` for `Range[i32]` (codegen saw {i64,i64,i1} for {i32,i32,i1}). Their numeric arguments now match exactly, through one helper, numeric_types_differ, which ref_numeric_pointees_differ and the auto-reference rule also use. - One reader of a literal's context. numeric_literal_expected_type (the literal) and untyped_literal_context_type (literal expressions) read the demand separately; the literal now asks the latter, which also sees a Result demand's Ok payload (§4.9): `fn f() -> Result[i32, E]: 2` was refused as an isize narrowing. - Law 2's order. Literal arguments bind a generic's parameters after the typed arguments, but before the call's demand: every argument is an operand. Binding the demand first made `ident(3)` at `Option[i32]` bind T := Option[i32]. Under D114 the operand `3` binds T := isize, so law 2's own example `let x: Option[i32] = ident(3)` is now refused; the fixture spells `3i32` and the conflict goes to a ruling. - A literal arm is checked again for its literals only: an `if` arm's condition (`.BoolVal(b) => if b: 1 else: 0`) was re-checked after the match arm's scope closed, "undefined variable". - Law 2 through `with`: Form 2's value is its binding (§7.2), so a demand on `with List.new() as mut out` binds the List's T before the body.
…g it Literal locals, ranges and globals that feed an i32 say so (`: i32`, `0i32..`, `List[i32]`, `Range[i32]`), in the behavior fixtures, the lib programs the pre-D runner builds (map, sequence, temporary-exit cases) and the programs embedded as strings. Three slice fixtures printed wrong answers before the slice rule (an `[]isize` read as `[]i32`); they now pass i32 slices. Layout tests that bind T from a literal (`record_size(7)`) expect isize; an expected error names `isize and str`.
… auto-ref widens - `let r: Range[i32] = 2..7` types the bounds from the demand (§4.2.1 rule 1), as a demanded collection types its elements; it was a Range[isize] refused by the annotation. - `1 in w` at `contains(item: &i32)` retypes the literal before the membership signature check, so the test for a non-bool `contains` reaches its own error again. - The auto-reference rule accepts a narrower numeric argument at `&T` (§4.2.6 widens on every argument; `v64.contains(u)` with `u: u32`) and refuses only a narrowing. Materializing the widened temporary for a user `&i64` parameter is #2336; the refusal test is withdrawn. - The named "same type" comparison error now precedes the generic compatibility error so it is the one reported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements D114 (docs/meetings/2026-10-08-D114-isize-is-the-targets-size-width.md) with the 2026-10-09 follow-up (untyped constants; locals not typed by use; each i32 target judged).
isizeat the target width; unsuffixed literal defaultisize, range-checked at the target width; len family, count, position, capacity, find, index_of and the enumerate index areisize.letconstants become untypedconst(§9.1b).??literal fallbacks, literalreturns, literal-onlyifoperands, literal arms beside a view, tuple literal arms,?? &-1, nested literal joins (an ICE), narrowing into an implicitOk(an ICE),isize/usizeto_string.isize; ids, flags, masks, stored AST/IR widths, source lines, parsed values and C widths stayi32(list for Eric to follow).Draft until the battery is green. Filed while working: #2325, #2326.