Repository navigation
D113 brackets make a Vec; D114 isize is the target's size width (rulings and spec projection) - #2281
Merged
Merged
Conversation
added 3 commits
October 8, 2026 18:42
Eric's ruling (2026-10-08), verbatim: brackets make a Vec, unless a fixed array type is demanded; a literal that is never grown or retained needn't touch the heap. Supersedes D93's fixed-array default. Two points to rule before the §4.3c projection: the element default (the ruling says Vec[i64]; §4.2.1 says i32) and whether HashSet/BTreeSet literals stay. The compiler is non-compliant; nothing is implemented.
Eric's follow-up rulings, verbatim in the entry: the closing spec line becomes "A bracket literal is a Vec[T], unless the demanded type is another collection that can be built from a list, such as a fixed array or a set. Then the literal builds that collection." Duplicate constants in a literal demanded as a set warn; a Vec keeps every element (`["a", "a"]` is a Vec of length 2). Whether the list of collections stays closed is a separate brief. The element default is D114's.
…ec projection of D113 and D114 D114, Eric's ruling (2026-10-08), verbatim in the entry: isize/usize are C's ptrdiff_t/size_t width, not pointer width (amends D108's definition; len() returning isize stands); unsuffixed integer literals default to isize everywhere, bracket literals included; literals and comptime arithmetic are checked at the target's width; values not bounded by memory use a fixed width, and a serialized or C-layout struct with an isize field warns. No code may assume an isize width; supported targets today are 64-bit hosts and wasm32. CLAUDE.md gains that line. Spec: §4.1 (the size-width definition replaces the stale pointer-width sentence), §4.2.1 (the isize default, the target-width check), §4.3a and §4.3c (D113: brackets make a Vec unless a fixed array or a set is demanded; storage is the compiler's; set duplicates warn; the repeat form follows the same rule). with_for_ai.md and the Go migrator spec drop the i32 default. The compiler is non-compliant with both until implemented.
ehartford
marked this pull request as ready for review
October 9, 2026 01:58
ehartford
pushed a commit
that referenced
this pull request
Oct 9, 2026
#2281 edited docs/spec/guide/with_for_ai.md and merged as docs-only, so nothing regenerated src/InitTemplates.w and cli-selfhost-project-tests (`with init` writes the guide as AGENTS.md) went red on main. Generated by tools/gen_init_templates.w.
This was referenced Oct 9, 2026
Two fixes for migrating STC: an index in an assignment target, and ternaries as if expressions
#2285
Merged
ehartford
added a commit
that referenced
this pull request
Oct 9, 2026
…ed (#2286) * D113: brackets make a Vec; a fixed array or set is built where demanded A bracket literal is a Vec[T] unless the demanded type is another collection built from a list (a fixed array, HashSet, BTreeSet). A use of a let-bound literal that demands a fixed array, including through `&xs`, is a demand like a Vec or set one (D93). A duplicate string or integer constant in a literal built as a set warns. Spec change (D113, §4.3c): tests that relied on the fixed-array default now demand the array they test; the dynamic rest binding they would otherwise need is #2283. * Regenerate the init templates from with_for_ai.md #2281 edited docs/spec/guide/with_for_ai.md and merged as docs-only, so nothing regenerated src/InitTemplates.w and cli-selfhost-project-tests (`with init` writes the guide as AGENTS.md) went red on main. Generated by tools/gen_init_templates.w. * D113: a Vec literal consumes its elements; a VecRange cannot outlive a temporary; every demand counts The battery on D113 found three defects that the fixed-array default had hidden: - A whole Drop local placed in a Vec or set literal was moved by MIR, but Sema never marked it moved: `let a: Vec[W] = [tmp]` then `tmp.id` read the vacated local (printed 0). Since #605 only array targets were marked, on the claim that other collections manage element ownership separately. They don't. Every target now marks the element consumed. - A VecRange (`split_at`, `split_at_mut`, `range`) views its Vec but was not ephemeral, so `mk().split_at(1)` bound two views into a Vec freed at the end of the statement. VecRange is ephemeral now, like CStr, and the existing temporary-borrow check refuses it. New test: err_vecrange_of_temporary. - D93 recorded a demand only where a use mismatched the binding's type. Under D113 a `&Vec` use already matches the default, so it went unrecorded, and two disagreeing demands became a plain mismatch at the first use. Every expected type checked against a literal's binding is now a demand, and the error names both at the second use again. Tests that relied on the fixed-array default now demand their arrays (spec change, D113): err_1367 (two files), behav_for_full_patterns, d_acceptance slice_pat_* and dump_typed_d22_contextual_joins (a sequence is a Vec now). err_split_at_index_type names `Vec.split_at`. err_split_at_mut_readonly_receiver tests a read-only `&Vec` receiver. That is the read-only case for a Vec: a `let` owner may call a `mut fn` (storage-types note: mutation through a marked operation is not rebinding). --------- Co-authored-by: Eric Hartford <[email protected]>
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.
Eric's rulings of 2026-10-08, canonized verbatim: D113 (brackets make a Vec unless a fixed array or a set is demanded; storage is the compiler's; set duplicates warn; a Vec keeps every element) and D114 (isize/usize are C's size_t/ptrdiff_t width; unsuffixed integers default to isize everywhere; literals and comptime checked at the target width; values not bounded by memory use fixed widths; no code assumes an isize width). D93 superseded in part, D108's definition amended. Spec §4.1, §4.2.1, §4.3a, §4.3c; CLAUDE.md/AGENTS.md line. No implementation; the compiler is non-compliant with both. spec-inventory-check green (docs only).