Skip to content

Give min and max the kind of their untyped arguments - #25

Merged
umputun merged 1 commit into
masterfrom
fix/minmax-untyped-float
Aug 19, 2026
Merged

Give min and max the kind of their untyped arguments#25
umputun merged 1 commit into
masterfrom
fix/minmax-untyped-float

Conversation

@paskal

@paskal paskal commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #24, which merged one commit before this one.

max(5, 4.0) has an untyped float type even though the integer argument wins, so max(5, 4.0) / 2 * 10 is 25 in Go while the evaluator computed 20: it returned the winning argument as an integer and divided as one. The result now takes the kind of the arguments, float when any of them is an untyped float.

A right shift count is bounded by a constant rather than measured against the width of the value. Shifting further than the value is wide keeps giving the same result, so the bound reaches it without inspecting the operand, and math/big is no longer needed.

The rest is tests. They cover the error path of every operand position, the declaration paths that are skipped, and the literal kinds that carry no value, which brings the package back to full statement coverage; it stands at 93.2% on master because the tests removed with the old evaluator were never replaced.

…ator

max(5, 4.0) has an untyped float type even though the integer wins, so
max(5, 4.0) / 2 * 10 is 25 and not 20. A right shift count is bounded by a
constant instead of the width of the value, which reaches the same result
without measuring it.

Tests cover every branch of the evaluator, including the error paths of each
operand position, and the package is back to full statement coverage.
@paskal
paskal requested a review from umputun as a code owner August 19, 2026 02:07
@umputun
umputun merged commit c22c170 into master Aug 19, 2026
2 checks passed
@umputun
umputun deleted the fix/minmax-untyped-float branch August 19, 2026 02:09
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.

2 participants