Skip to content

Symbol type parameters can be piracy#375

Open
timholy wants to merge 2 commits into
JuliaTesting:masterfrom
timholy:teh/pirate_symbols
Open

Symbol type parameters can be piracy#375
timholy wants to merge 2 commits into
JuliaTesting:masterfrom
timholy:teh/pirate_symbols

Conversation

@timholy
Copy link
Copy Markdown
Contributor

@timholy timholy commented Apr 23, 2026

As described in #374, types like

ClosedInterval{T} = Interval{:closed,:closed,T}

from IntervalSets blocked piracy-detection because :closed Symbol params caused is_foreign to return false unconditionally.

Fundamentally, this revealed problems with the heuristic used by is_foreign. This was essentially acknowledged as a problem in the comments.

The strategy taken here is to change the heuristic: if the combination SomeType{:foo} appears in the module that defines SomeType, then this combination is treated as a foreign type. If no such combination exists, then the Symbol is treated as a user-defined dispatch tag, and the type is treated as a user-defined type. To avoid the need for "grepping" through source code, there is one additional requirement for it to be treated as foreign: the type/symbol combination must be defined as a type alias (UnionAll) in the owning module.

Fixes #374.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

As described in JuliaTesting#374, types like

    ClosedInterval{T} = Interval{:closed,:closed,T}

from IntervalSets blocked piracy-detection because `:closed` Symbol
params caused `is_foreign` to return `false` unconditionally.

Fundamentally, this revealed problems with the heuristic used by
`is_foreign`. This was essentially acknowledged as a problem in the
comments.

The strategy taken here is to change the heuristic: if the combination
`SomeType{:foo}` appears in the module that defines `SomeType`, then
this combination is treated as a foreign type. If no such combination
exists, then the Symbol is treated as a user-defined dispatch tag, and
the type is treated as a user-defined type. To avoid the need for
"grepping" through source code, there is one additional requirement for
it to be treated as foreign: the type/symbol combination must be defined
as a type alias (UnionAll) in the owning module.

Fixes JuliaTesting#374.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.61%. Comparing base (cdc679f) to head (5c672c8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
+ Coverage   87.47%   87.61%   +0.13%     
==========================================
  Files          12       12              
  Lines         527      541      +14     
==========================================
+ Hits          461      474      +13     
- Misses         66       67       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timholy
Copy link
Copy Markdown
Contributor Author

timholy commented Apr 28, 2026

I saw that the one failure was about a label. I don't have suitable privileges to add labels, but I did add an entry to the CHANGELOG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect_piracies misses some cases

2 participants