fix(lower): box both operands of == on concrete collection values #326
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/209-stack-value-equality"
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?
Closes #209
What
a == banda != bon two values of the same concrete collection type (ArrayStack,ConsStack,ArrayQueue,BankersQueue,RingList) failed: theEqualsofStack,QueueandListis anextendof the trait, whoseselfandother: Selfare trait-typed values, butlowerOperatorpassed both operands in as records, so the IR verifier refused the call (argument 0 is Object(Stack<Int64>) and %0 is Record(...ArrayStack__Int64)) in the VM and natively.How
lowerOperatornow coerces its operands withreceiverOfTraitExtension, the coercion a call of such a member already applies to its receiver: the left operand is boxed with the trait's table, and every further operand of the same type (theSelfparameter ofEquals/Compare) with it. Operands of another type and members that are not of a traitextendare unchanged. Mixed implementations (ArrayStack == ConsStack) stay a checker error, as before.Tests
compiler/tests/lower-calls.test.trb:==and!=on twoCrate<Int>whoseEqualsisextend<Item: Equals> Shelf<Item>lower to verified IR withObject(Shelf<Int64>)operands.tests/conformance/concrete-collection-equality.trb: equal, different length, different order and empty vs empty for every implementation, plus changed copies andStringitems.cons-stack-persists.trbcompares twoConsStacks with==directly; its trait-typed helper stays only for theConsStackvsArrayStackcomparison. The stale note inbankers-queue.trbis gone.Seed impact: none (no syntax, native, driver flag or string-looked-up std name).
a53f37bbce457466de70457466de702cd7d0a174Approved.
operandsOfTraitExtensionreuses the receiver coercion for the left operand and boxes further same-typed operands; other types and non-trait extends pass through unchanged. Empty operand list handled.Non-blocking: none.