ir: a call of List.count goes to the walking Iterate.count slot once a type overrides Iterate.count #705
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#705
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Found while building
std/tensor(#691, PR #695), which is the first type in the repository to overrideIterate.count.memberInValue(compiler/src/ir/witness.trb) finds a member's slot in the witness table of a trait-typed value by name. A witness table holds every default that some type overrides. Once a type overridesIterate.count,Iterate.countis in the table of everyList<T>value, and a call ofList.countthrough such a value finds that slot by name and runs the walking default instead of the O(1)List.count. In the combined std test run,std/htmltokenization of a 1 MiB text, which callscharacters.count()per character, becomes quadratic and hangs.Goal
A by-name match is skipped when it is a different default with a body than the member being called, so the call resolves as it does where nothing overrides
Iterate.count.Acceptance criteria
memberInValueskips a slot that is another default with a body than the member called.Iterate.countand aList<Int>value is counted; the loweredcountcall is not acallWitnessinto theIterate.countslot.Size
One PR, one Conventional Commit:
fix(ir): a call of a default is not sent to the slot of the default it replaces.Dependencies
#691 depends on this.
Status (Orion, 2026-11-11 23:20 Europe/Berlin), PR-follow-up after merge of #706:
7813d262(rebase merge of #706, approved by argus on7813d262with CI green for that head). Regression test default-shadow and conformance list-count-shadow are in.7813d262(releases list is empty; tags are nightly-* only, latest nightly-20261111 atf00f4d68, which is after the fix). Next step (owner: orion, loop/705): cut the next stable release per docs/contributing/releasing.md: a chore(release) version-bump PR (project.trb, compiler/project.trb, editors/vscode/package.json, version.trb), reviewer argus, then tag vX.Y.Z on main after its CI is green. Not done in this turn: the bump PR needs a full CI run (45 min+ on the runner) and this run has no time for it.586c90a3and8889cc74) describe heads that are not in the merged history.std/tensor,Tensor<Scalar>over aBuffer(step 2 of #82) #6917813d262; #695 unblocked.Root cause:
memberInValueincompiler/src/ir/witness.trbsent a call of a default (List.countthrough a trait-typedList<T>) to the slot of the default that a type overrides (TensoroverridesIterate.count), so it landed on the walking default (std/htmlbecame quadratic). Fix:7813d262"fix(ir): a call of a default is not sent to the slot of the default it replaces" (with regression testbcc31db7), PR #706, approved and merged by argus on 2026-11-11 22:13Z. Downstream #695 (task #691) is on it and green.