Repository navigation
Two fixes for migrating STC: an index in an assignment target, and ternaries as if expressions - #2285
Merged
Merged
Conversation
added 3 commits
October 8, 2026 20:12
check_runtime_index_operand checked the index with no expected type, so an `if` in the index of an assignment target was typed as a statement (Unit): `xs[if c: 1 else: 2] = v` was refused, on main too. The migrator emits exactly that for C's `tree[cond ? a : b].freq++` once a pure ternary is an if expression (zlib deflate/trees). The index is checked in value context. The diagnostic now names the type it found.
C's ?: evaluates one arm, as With's if expression does. The value lowering
hoisted every ternary into a temp and an if statement, so a pure context
(an initializer-list element, a call's argument inside one) refused it:
STC's `Self out = {_i_new_n(T, n), 0, n}` expands to
`malloc((size_t)(1 ? n : -1))` there, and every vec constructor was
untranslatable. A ternary whose condition and arms need no statement is
now the expression; hoisting stays for arms that need statements.
c-migrator-core-tests gains the case.
Per D112 no corpus re-promotes for this: corpus-migrator-gate migrates
each afresh and runs its upstream tests (pcre2's regenerated output, for
one, shrinks by ~3,100 lines of hoisted temps).
…n is spelled with its type `give ? s->owner : 0` became `if give != 0: s.owner else: null`, and `null` has no type of its own (an if arm never takes the other arm's), so the c_facade_children fixture stopped compiling. The null arm is now cast to the ternary's type, as C's NULL already was. The migrate-core check gains the case.
Contributor
Author
|
Battery GREEN on f329092 (stack top: #2280, #2284, #2285, #2286), The first battery, on 859e562, was red. It found three defects the fixed-array default had hidden, plus a red main, all fixed in f329092 and f57ba3c:
|
This was referenced Oct 9, 2026
ehartford
marked this pull request as ready for review
October 9, 2026 05:41
ehartford
added a commit
that referenced
this pull request
Oct 9, 2026
* tools/rename_vec_to_list.w: D118 step (c) identifier rename and string-literal report (#2296) * seed.lock: nightly-20261009-local-1-2638c97adaf8, the first seeds that accept List (D118 step a) darwin-aarch64, linux-x86_64 and windows-x86_64 cut from main 2638c97, each built on its own host to a stage2 == stage3 fixpoint over all 16 units. The aarch64 platforms keep their .version pins (#2305). * corpora: re-promote pcre2, zlib, c_algorithms and tommyds (D112) The renamed migrator is a new pin. The regenerated modules also carry the migrator changes merged since the last promotion (#2285: a pure ternary is an if expression), which no promotion had taken in. * D118 step (c)+(d): the growable sequence is List; Vec names no type (#2296) A Lexer-driven rename of identifier tokens (tools/rename_vec_to_list.w: a word part exactly vec/Vec/VEC, incl. member names after a dot; with_* runtime symbols are pinned by the seed and keep their names) and a pass over string literals and comments (capitalized Vec words; Rust's Vec<T>, Vector, Vec2 kept). The step-(a) alias is gone; 'Vec' is an error naming List in type and value position. vec-name joins the ceremony census at zero. StdGeneric's List variant is spelled Sequence while the step-(a) seed drives the build (its alias misses member names after a dot, #2305). The ABI hash is re-recorded: TypeLayout.w's diff is the rename only. * build/seed.w: own the pin-block asset name until the seed copies interior views (#2307) seed-driver read a freed buffer: `pending_asset = line.slice(..).trim()` stores a view into the temporary slice as a str, and the D111 seed lowers that as copy+retain, a no-op for an interior pointer. .to_owned() copies; it comes out with the step-(d) seed that carries the #2307 fix. * D118 step (c): the rename's misses the battery found (#2296) benchmarks/ and tests/ were outside the first file list; identifiers in f-string holes are inside string tokens, so the identifier pass skipped them (`{vec.len()}`, `{vec_closed}`, `{local_vec()}`, checked against every renamed name); the module std.collections.sorted_vec is the file sorted_list.w. * sorted_list.w: drop three redundant explicit Unit returns the file rename re-presented for review --------- 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.
Groundwork for STC (stdlib sourcing plan, Phase 3).
check_runtime_index_operandchecks the index in value context, and the diagnostic names the type. Test:behav_if_index_in_assignment_target.w.ifexpression. Hoisting every ternary into a temp made STC's vec constructors untranslatable (malloc((size_t)(1 ? n : -1))inside an initializer list). Under D112 nothing re-promotes; the drift report shows pcre2 21, zlib 15, c-algorithms 1 and tommyds 3 modules would change, and the migrator gate passes on all four fresh migrations.0arm of a pointer ternary is cast to the ternary's type, asNULLalready was. Otherwise it became a barenull, which has no type (an if arm never takes the other arm's type), and the c_facade_children fixture stopped compiling. The migrate-core check gains the case; it fails before the fix.