Skip to content

Borrow operator operands - #1610

Merged
sbillig merged 1 commit into
argotorg:masterfrom
sbillig:fix-operator-view-operands
Sep 27, 2026
Merged

sbillig merged 1 commit into
argotorg:masterfrom
sbillig:fix-operator-view-operands

Conversation

@sbillig

@sbillig sbillig commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

a == b moved a non-Copy b, even though Eq::eq takes its operand as a view and a.eq(b) borrows it. Operator type checking recorded the coerced parameter type (view T) as the right-hand operand's own type, so lowering read b into a view temporary, which moved b whenever it had no storage slot.

Operator operands are now checked against the parameter type like call arguments and keep their own type; the call boundary forms the view.

  • Lowering no longer strips views from tuple, array, array-repeat, cast and record literals; those workarounds only existed for retyped operands. Scalar operands are no longer given memory just to be viewed, which shrinks several Sonatina IR snapshots.
  • The loop-prefix certifier accepts a loop bound reached through copies of the parameter. i < count now has the same shape as i.lt(count), which the certifier previously rejected.
  • The semantic_borrowck/aggregate_equality fixture, which pinned the moves, is replaced by runtime checks in fe_test/aggregate_equality.fe that reuse the right-hand operands.

Field operands such as a.x == b.x additionally rely on #1581.

check_ops_trait recorded the coerced parameter type as the right-hand
operand's own type, so `a == b` read `b` into a view temporary; when `b`
had no storage slot, that read moved it. Check the operand against the
parameter like a call argument and keep its type. The call boundary
forms the view, as it already does for `a.eq(b)`.

Lowering no longer strips views from tuple, array, record and cast
literals, and scalar operands are no longer given memory to be viewed.
The loop-prefix certifier accepts a bound reached through copies of the
parameter, the shape `i < count` now shares with `i.lt(count)`.
@sbillig sbillig changed the title Borrow operator operands instead of retyping them Borrow operator operands Sep 27, 2026
@sbillig
sbillig merged commit 4a7579a into argotorg:master Sep 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant