Skip to content

Construct generic results via lohi/midrad#22

Merged
timholy merged 1 commit into
mainfrom
teh/constructor-bugs
Jul 14, 2026
Merged

Construct generic results via lohi/midrad#22
timholy merged 1 commit into
mainfrom
teh/constructor-bugs

Conversation

@timholy

@timholy timholy commented Jul 14, 2026

Copy link
Copy Markdown
Member

typemin, typemax, intersect and hull built their result by calling the two-argument constructor TN(lo, hi), which assumes the type is parametrized by its lower and upper span. A type parametrized some other way received its arguments under the wrong interpretation: for a midpoint and radius, hull read the upper bound as a radius, so hulling a value with itself was not even idempotent, and typemin produced a NaN midpoint from Inf - Inf.

intersect and hull now use lohi, which is the interface's hook for building a value from a span. typemin and typemax use midrad with a zero radius; going through lohi would ask a midpoint-parametrized type to evaluate Inf - Inf.

MidRad is a new test package parametrized by midpoint and radius. Every span assertion is run against both it and Interval, so generic code that silently assumes a lo/hi parametrization now fails the test suite; Interval alone cannot detect it.

Assisted-by: Claude Opus 4.8 noreply@anthropic.com

`typemin`, `typemax`, `intersect` and `hull` built their result by calling
the two-argument constructor `TN(lo, hi)`, which assumes the type is
parametrized by its lower and upper span. A type parametrized some other
way received its arguments under the wrong interpretation: for a midpoint
and radius, `hull` read the upper bound as a radius, so hulling a value
with itself was not even idempotent, and `typemin` produced a `NaN`
midpoint from `Inf - Inf`.

`intersect` and `hull` now use `lohi`, which is the interface's hook for
building a value from a span. `typemin` and `typemax` use `midrad` with a
zero radius; going through `lohi` would ask a midpoint-parametrized type
to evaluate `Inf - Inf`.

`MidRad` is a new test package parametrized by midpoint and radius. Every
span assertion is run against both it and `Interval`, so generic code that
silently assumes a lo/hi parametrization now fails the test suite;
`Interval` alone cannot detect it.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.87%. Comparing base (b2d5e09) to head (2fc8433).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #22   +/-   ##
=======================================
  Coverage   93.87%   93.87%           
=======================================
  Files           2        2           
  Lines         147      147           
=======================================
  Hits          138      138           
  Misses          9        9           

☔ View full report in Codecov by Harness.
📢 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 timholy merged commit 778b20c into main Jul 14, 2026
5 checks passed
@timholy timholy deleted the teh/constructor-bugs branch July 14, 2026 21:01
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