Skip to content

use more precise structural inspection of types for ambiguity exclusions #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vtjnash
Copy link
Contributor

@vtjnash vtjnash commented Apr 28, 2025

Should be slightly more robust, since subtyping already implements these queries with much more finesse than is going to be true of a re-implementation of the query here.

Should be slightly more robust, since subtyping already implements these
queries with much more finesse than is going to be true of a
re-implementation of the query here.
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.35%. Comparing base (484c23f) to head (73643da).

Files with missing lines Patch % Lines
src/ambiguities.jl 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
+ Coverage   86.93%   87.35%   +0.41%     
==========================================
  Files          11       11              
  Lines         513      506       -7     
==========================================
- Hits          446      442       -4     
+ Misses         67       64       -3     

☔ 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.

@vtjnash
Copy link
Contributor Author

vtjnash commented Apr 28, 2025

Do you still care about v1.2- here? Apparently it needs some fix to avoid a julia bug, but I don't know if that is actually helpful to figure out?

@lgoettgens
Copy link
Collaborator

Thanks for the PR @vtjnash, from a first glance, this looks like a great simplification. I'll give this a more detailed review once the minimum supported julia version has been increased (to be done for the next minor release).

@vtjnash
Copy link
Contributor Author

vtjnash commented Apr 29, 2025

I can also fix the support for those versions, I just wanted to check first if this PR and that support was considered useful

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Sounds like a good idea, thank you!

Comment on lines +33 to +37
if num_ambiguities_ != num_ambiguities
@show exclude
println(strout)
println(strerr)
end
Copy link
Member

Choose a reason for hiding this comment

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

How is this related to the rest of the changes in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just debugging for the relevant tests if they change reporting

@@ -44,7 +49,7 @@ include("preamble.jl")
check_testcase([PkgWithAmbiguities.ConcreteType], total - num_ambs_ConcreteType)

# exclude abstract supertype without callables and constructors
check_testcase([PkgWithAmbiguities.AbstractType], total)
check_testcase([PkgWithAmbiguities.AbstractType], total - num_ambs_SingletonType - num_ambs_ConcreteType)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like an unwanted behavioral change.
If I exclude AbstractType, according to the docstring, this excludes ambiguities of the constructor AbstractType and the functor (::AbstractType).
However, after this change, it also ignores ambiguities of the constructor SingletonType (which IMO is a completely different function) and the functor (::SingletonType) (which shares the methodtable with (::AbstractType) for each SingletonType object created).
The former change seems clearly unwanted to me, for the latter one I am not sure what to do best here. If possible, I think I would like to keep the current behavior.

Note, however, that with the current behavior, excluding ConcreteParameterizedType also excludes all constructors ConcreteParameterizedType{T} for any T.

Since we already have a breaking change in master, it would be fine to slightly change the semantics of exclusion here, but that would need some good explanation of the new semantics in the docstring of test_ambiguities and in the changelog.

Copy link
Contributor Author

@vtjnash vtjnash May 5, 2025

Choose a reason for hiding this comment

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

Okay, I've switched it back to doing only structural inspection instead of the subtyping queries and just simplified them to stay in the type domain where the comparisons can be made more reliable. It is less powerful (since it cannot realize that SingletonType is an implementation of AbstractType) but that keeps the existing named-based exclusion behavior.

@vtjnash vtjnash changed the title use subtyping instead of structural inspection for ambiguity exclusions use more precise structural inspection of types for ambiguity exclusions May 5, 2025
@vtjnash vtjnash force-pushed the jn/ambig-getobj branch from 60824c0 to 0a96266 Compare May 5, 2025 21:06
… types

Even though that means there are cases that will be impossible to
exclude, the author of Aqua confirmed that is intentional.
@vtjnash vtjnash force-pushed the jn/ambig-getobj branch from 0a96266 to 73643da Compare May 5, 2025 21:07
@vtjnash vtjnash requested a review from lgoettgens May 6, 2025 17:10
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.

3 participants