Skip to content

Reduce method ambiguities by disambiguating ConstantField binary ops#5313

Merged
glwagner merged 3 commits intomainfrom
glw/reduce-ambiguities
Feb 20, 2026
Merged

Reduce method ambiguities by disambiguating ConstantField binary ops#5313
glwagner merged 3 commits intomainfrom
glw/reduce-ambiguities

Conversation

@glwagner
Copy link
Copy Markdown
Member

Summary

  • Add op(a::ConstantField, b::ConstantField) disambiguating method inside define_binary_operator to resolve ambiguity between op(a::AbstractField, b::ConstantField) and op(a::ConstantField, b::AbstractField) (since ConstantField <: AbstractField)
  • Fixes 5 pre-existing ambiguities (one each for +, -, /, ^, *)
  • Lowers ambiguity threshold from 355 to 328

Test plan

  • Verified detect_ambiguities(Oceananigans; recursive=true) returns 328 (down from 333)
  • CI passes quality assurance tests

🤖 Generated with Claude Code

Add `op(a::ConstantField, b::ConstantField)` to resolve ambiguity between
`op(a::AbstractField, b::ConstantField)` and `op(a::ConstantField, b::AbstractField)`
since ConstantField <: AbstractField. This fixes 9 ambiguities (one per binary op).

Also add explicit `<(::AbstractField, ::Missing)` and `<(::Missing, ::AbstractField)`
to disambiguate against Base's Missing methods, fixing 2 more ambiguities.

Lowers the ambiguity threshold from 355 to 326 (11 fewer total).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@glwagner glwagner force-pushed the glw/reduce-ambiguities branch from eb0e217 to 30fd27e Compare February 20, 2026 01:01
# Do not increase this number. If ambiguities increase, resolve them before merging.
number_of_ambiguities = length(detect_ambiguities(Oceananigans; recursive=true))
@test number_of_ambiguities <= 355
@test number_of_ambiguities <= 326
Copy link
Copy Markdown
Member

@navidcy navidcy Feb 20, 2026

Choose a reason for hiding this comment

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

this fails?

[2026/02/20 01:41:50.791] INFO  testing quality assurance via Aqua
Aqua: Test Failed at /var/lib/buildkite-agent/builds/nautilus-13/clima/oceananigans/test/test_quality_assurance.jl:13
  Expression: number_of_ambiguities <= 326
   Evaluated: 338 <= 326

https://buildkite.com/clima/oceananigans/builds/29528#019c78b4-6757-4741-a5bc-5b27237e6ea5/L693

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i think I get a different answer for this locally than here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I believe there are some ambiguities introduced by some extensions, so you need to ensure those are loaded as well.

@glwagner
Copy link
Copy Markdown
Member Author

@giordano you'll notice that I (or rather claude) accidentally increased the number of ambiguities on #5309. (I hope assassins don't show up at my house later....)

This PR fixes the ambiguities... before #5309 we were at 345:

@test number_of_ambiguities <= 345

now hopefully we will be down to 338.

@giordano
Copy link
Copy Markdown
Collaborator

No, I missed that 😭 (otherwise I'd have complained loudly 😈) But thanks for fixing it afterwards!

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.24%. Comparing base (7cda325) to head (db47651).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/AbstractOperations/AbstractOperations.jl 0.00% 2 Missing ⚠️
src/AbstractOperations/binary_operations.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5313      +/-   ##
==========================================
- Coverage   73.25%   73.24%   -0.01%     
==========================================
  Files         397      397              
  Lines       22460    22463       +3     
==========================================
  Hits        16453    16453              
- Misses       6007     6010       +3     
Flag Coverage Δ
buildkite 68.61% <0.00%> (-0.01%) ⬇️
julia 68.61% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@glwagner glwagner merged commit e4ebdcb into main Feb 20, 2026
79 of 80 checks passed
@glwagner glwagner deleted the glw/reduce-ambiguities branch February 20, 2026 15:11
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.

3 participants