Skip to content

Fix dispatch ambiguities by restricting aud to audgz (d>0:shp)#255

Merged
sbscholz merged 2 commits intoSacBase:masterfrom
rubenhensen:fix/dispatch-ambiguity
Apr 26, 2026
Merged

Fix dispatch ambiguities by restricting aud to audgz (d>0:shp)#255
sbscholz merged 2 commits intoSacBase:masterfrom
rubenhensen:fix/dispatch-ambiguity

Conversation

@rubenhensen
Copy link
Copy Markdown
Contributor

Replace [d:shp] with [d>0:shp] in commutative overload pairs where one function was more specific in one arg position but less specific in another, causing the new dispatch rule to reject them.

  • Quaternion.xsac: * operator scalar×aud / aud×scalar overloads
  • arraybasics.mac: MODARRAY_AxVxS conflicting with MODARRAY_AxSxA
  • ArrayTransform.xsac: WHERE AxS / SxA overloads
  • ComplexArrayArith.xsac: MAP_BIN AxS / SxA overloads

Has to do with: https://gitlab.sac-home.org/sac-group/sac2c/-/merge_requests/637

Replace [d:shp] with [d>0:shp] in commutative overload pairs
where one function was more specific in one arg position but less
specific in another, causing the new dispatch rule to reject them.

- Quaternion.xsac: * operator scalar×aud / aud×scalar overloads
- arraybasics.mac: MODARRAY_AxVxS conflicting with MODARRAY_AxSxA
- ArrayTransform.xsac: WHERE AxS / SxA overloads
- ComplexArrayArith.xsac: MAP_BIN AxS / SxA overloads
Comment thread include/arraybasics.mac
Comment thread src/structures/ArrayTransform.xsac
* MODARRAY_AxVxS: revert d>0 -> d:shp. The pair AxVxS / AxSxA is in
  fact safe because their `idx` types are disjoint (`int[.]` vs scalar
  `int`), so no call can match both. The previous restriction was a
  workaround for an over-strict dispatch rule in sac2c which has now
  been corrected to recognise disjoint positions.

* WHERE: add WHERE_SSS, an explicit all-scalar overload using a normal
  conditional (`p ? A : B`) instead of a with-loop, as Sven suggested.
  WHERE_SSS is uniformly more specific than WHERE_SxS, so dispatch
  picks it for fully scalar arguments and avoids the WL overhead.
@rubenhensen rubenhensen requested a review from sbscholz April 26, 2026 10:59
Copy link
Copy Markdown
Member

@sbscholz sbscholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now

@sbscholz sbscholz merged commit 75a8025 into SacBase:master Apr 26, 2026
2 checks passed
@rubenhensen rubenhensen deleted the fix/dispatch-ambiguity branch April 28, 2026 06:58
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.

2 participants