Skip to content

Report a domain error when const folding ** yields a complex number (#228) - #236

Merged
zimri-leisher merged 1 commit into
develfrom
228-complex-pow-fold
Sep 8, 2026
Merged

zimri-leisher merged 1 commit into
develfrom
228-complex-pow-fold

Conversation

@zimri-leisher

Copy link
Copy Markdown
Collaborator

Fixes #228.

Const-folding ** calls Python float.__pow__, which returns a complex number
for a negative base and a fractional exponent instead of raising. The folder
only expects int, float, Decimal or bool, so it died on assert False, folded_value in CalculateConstExprValues.visit_AstBinaryOp. The Decimal path
for the same expression raises decimal.InvalidOperation and is already
reported as Domain error; this makes the float path agree.

Red/green: the two new sequences (F64(-8.0) ** 0.5 and (-2.0) ** F64(0.5))
crash the compiler with an AssertionError before the change and report
Domain error after. The existing (-1) ** 0.5 test covers the Decimal path
and passes throughout.

🤖 Generated with Claude Code

…228)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zimri-leisher
zimri-leisher merged commit 0ffb2a7 into devel Sep 8, 2026
8 checks passed
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