ir: a call of List.count goes to the walking Iterate.count slot once a type overrides Iterate.count #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.