Skip to content

Fix unit promotion for same units, different context#845

Open
gpeairs wants to merge 1 commit intoJuliaPhysics:masterfrom
gpeairs:master
Open

Fix unit promotion for same units, different context#845
gpeairs wants to merge 1 commit intoJuliaPhysics:masterfrom
gpeairs:master

Conversation

@gpeairs
Copy link
Copy Markdown

@gpeairs gpeairs commented Mar 30, 2026

Unit promotion for "same units but different promotion context" uses a unit singleton instance as a type parameter, but it should use the type.

Example:

import Unitful: μm, mm, ContextUnits
μm2μm = ContextUnits(μm,μm)
μm2mm = ContextUnits(μm,mm)
x, y = promote(1.0μm2μm, 1.0μm2mm)
upreferred(x)

Before the fix:

ERROR: MethodError: no method matching (::Unitful.FreeUnits{(m,), 𝐋, nothing})()

After the fix:

1.0e-6 m

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@f1f3f32). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #845   +/-   ##
=========================================
  Coverage          ?   90.13%           
=========================================
  Files             ?       22           
  Lines             ?     1713           
  Branches          ?        0           
=========================================
  Hits              ?     1544           
  Misses            ?      169           
  Partials          ?        0           

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

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.

1 participant