Repository navigation
A statement where a number is expected is refused by both compilers - #2229
Merged
Rafael-SOWNet merged 1 commit intoOct 30, 2026
Merged
Conversation
A statement in a numeric position, such as the argument of sin or a summand, has no value: evaluation leaves sin(True) and True + 2 as written. The compilers each disagreed with that, differently: - FastExpression, which carries a statement as its truth value, took True as 1. So sin(x > 1) at 2 was 0.8414709848078965 and max(x > 1, 0) was 1. This came with #2209 and is unreleased. - The LINQ compiler threw KeyNotFoundException for sin(x > 1) and (x > 1)^2, from widening a bool to double. For max(x > 1, 0) it threw AngouriBugException, which asks for a bug report. Both are on 2.6.0. StatementPositions.Check now runs in both compilers, after the membership rewrite and before anything is compiled. A statement-valued node is a statement, or a provided or piecewise over one. It may stand at the root, as an operand of a connective, on both sides of an equality of statements, in an Iverson bracket, as a provided's or a piecewise's value or predicate, and in a set or a quantifier. Anywhere else it is refused with UncompilableNodeException, whose message points to iverson, the way to take a statement as a number. StatementInANumericPositionTest: 10 statements in numeric positions, refused by FastExpression and by LINQ over double and over Complex. All 10 fail without the check. Also 8 places where a statement is taken, which compile as before. Fixes #2227. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2229 +/- ##
=======================================
Coverage 86.68% 86.68%
=======================================
Files 309 310 +1
Lines 67660 67679 +19
Branches 19621 19627 +6
=======================================
+ Hits 58648 58665 +17
Misses 4895 4895
- Partials 4117 4119 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
a-statement-where-a-number-is-expected-is-refused
branch
October 30, 2026 07:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2227.
A statement in a numeric position, such as the argument of
sinor a summand, has no value: evaluation leavessin(True)andTrue + 2as written. Each compiler disagreed with that, in its own way:Trueas1.sin(x > 1)at 2 was0.8414709848078965, andmax(x > 1, 0)was1. This came with FastExpression compiles statements, provided and piecewise #2209 and is unreleased.KeyNotFoundExceptionforsin(x > 1)and(x > 1)^2, from widening abooltodouble. Formax(x > 1, 0)it threwAngouriBugException, which asks for a bug report. Both are on 2.6.0.StatementPositions.Checknow runs in both compilers, after the membership rewrite and before anything is compiled. A statement-valued node is a statement, or aprovidedorpiecewiseover one. It may stand:provided's or apiecewise's value or predicate;Anywhere else it is refused with
UncompilableNodeException, whose message points toiverson, the way to take a statement as a number."sin(x > 1)".ToEntity().Compile("x").Call(2)(0.8414709848078965, 0)"sin(x > 1)".ToEntity().Compile<double, double>("x")KeyNotFoundExceptionKeyNotFoundException"max(x > 1, 0)".ToEntity().Compile<double, double>("x")AngouriBugExceptionAngouriBugExceptionTests:
StatementInANumericPositionTesthas 10 statements in numeric positions, refused by FastExpression and by LINQ overdoubleand overComplex; all 10 fail without the check. It also has 8 places where a statement is taken, which compile as before. Full suite 18060/0, interactive trio, AOT smoke 73/0, all frameworks build.🤖 Generated with Claude Code