Skip to content

Constrain getindex arg type in @selectors macro#41

Merged
quinnj merged 1 commit intomainfrom
jq/constrain-selectors-getindex
Feb 12, 2026
Merged

Constrain getindex arg type in @selectors macro#41
quinnj merged 1 commit intomainfrom
jq/constrain-selectors-getindex

Conversation

@quinnj
Copy link
Member

@quinnj quinnj commented Feb 12, 2026

Summary

  • Fixes Too lax getindex method causes ambiguity downstream #40
  • The @selectors macro generated Base.getindex(x::$T, arg) with completely unconstrained arg, causing method ambiguities in downstream packages that define getindex on AbstractArray with specific index types (e.g. Reactant.jl#2398)
  • Added a SelectorIndex type alias (Union{KeyInd, Integer, Colon, Inds}) covering exactly the types that _getindex accepts, and constrained the macro-generated method to use it

Test plan

  • All existing tests pass (Pkg.test() — 251 tests)
  • Verified that types like TracedRNumber{Int64} (not subtypes of Integer) no longer match the constrained method, eliminating the reported ambiguity

🤖 Generated with Claude Code

…iguities (#40)

The @selectors macro generated `getindex(x::T, arg)` with unconstrained
`arg`, causing method ambiguities in packages that define getindex on
AbstractArray with specific index types (e.g. Reactant.jl).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@quinnj quinnj merged commit c068ec1 into main Feb 12, 2026
8 checks passed
@quinnj quinnj deleted the jq/constrain-selectors-getindex branch February 12, 2026 17:11
@giordano
Copy link

Thanks! Can we also get a new release which includes this change?

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.

Too lax getindex method causes ambiguity downstream

2 participants