Skip to content

feat: readable dimension-mismatch diagnostics - #30

Merged
adamek727 merged 1 commit into
mainfrom
feat/readable-dim-errors
Jun 17, 2026
Merged

feat: readable dimension-mismatch diagnostics#30
adamek727 merged 1 commit into
mainfrom
feat/readable-dim-errors

Conversation

@adamek727

Copy link
Copy Markdown
Owner

FUTURE_WORK v3.x quick win — the biggest day-to-day ergonomic improvement.

The BaseUnit member +, - and the six comparison operators now accept an operand of any dimension and static_assert that the exponents match. A dimension mistake reports one line:

error: static assertion failed: utl: cannot add quantities of different dimensions

instead of the previous overload-resolution wall of "no matching operator" + candidate notes.

  • Same-dimension behaviour is unchanged: mixed-precision promotion (std::common_type_t) and result-type mapping still apply; verified by the existing suite.
  • No new free operators — only the existing members were relaxed, so there is no risk of new ambiguity. Units that define their own operator+ (Temperature, Activity, …) keep their behaviour.
  • Single header regenerated; CHANGELOG + CLAUDE.md updated.

Verified locally: build (Werror), 48 tests, clang-format, zero-overhead, single-header --check in sync; and Length + Time / Length < Mass now emit the readable messages.

The BaseUnit member +, -, and comparison operators now accept an operand of any
dimension and static_assert that the exponents match, so adding/subtracting/
comparing incompatible quantities fails with a clear message (e.g. 'utl: cannot
add quantities of different dimensions') instead of an overload-resolution wall
of 'no matching operator' notes. Same-dimension behaviour (including mixed
precision and result-type mapping) is unchanged.

Regenerated the single header; updated CHANGELOG and CLAUDE.md.
@adamek727
adamek727 merged commit 5c68dbd into main Jun 17, 2026
6 checks passed
@adamek727
adamek727 deleted the feat/readable-dim-errors branch June 17, 2026 07:27
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