Repository navigation
Say which variable a compiled expression was not given - #688
Merged
Happypig375 merged 1 commit intoAug 4, 2026
Merged
Conversation
"a * x".ToEntity().Compile("x") raised
KeyNotFoundException: The given key 'a' was not present in the dictionary
which names neither the variable, nor the compilation, nor anything a caller of
Compile could act on. Both compilers did it: the one into a FastExpression and
the one into a Linq expression tree, each by reaching into its own dictionary of
arguments and letting the lookup fail.
A compiled expression is a function of the variables it was compiled over, so
one it does not mention is not something it can be given a value for. That is
now an UncompilableNodeException, which is what the compilers already raise for
a matrix or a derivative, and it names the variable and the ones that were
given.
Constants are unaffected: pi and e are substituted for their values before any
variable is looked up, so "pi * x" still compiles over x alone.
13 tests, 8 of which fail without the change. 4009 in all, 127 F#.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #688 +/- ##
==========================================
- Coverage 80.99% 80.42% -0.58%
==========================================
Files 155 156 +1
Lines 13687 12917 -770
Branches 1957 2122 +165
==========================================
- Hits 11086 10388 -698
+ Misses 1990 1921 -69
+ Partials 611 608 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
That names neither the variable, nor the compilation, nor anything a caller of
Compilecould act on. Both compilers did it — the one into aFastExpressionand the one into a Linq expression tree — each by reaching into its own dictionary of arguments and letting the lookup fail.Now
A compiled expression is a function of the variables it was compiled over, so one it does not mention is not something it can be given a value for.
UncompilableNodeExceptionis what both compilers already raise for a matrix or a derivative, so this is the exception a caller would already be catching.Constants are unaffected:
piandeare substituted for their values before any variable is looked up, so"pi * x"still compiles overxalone.Verification
13 tests, 8 of which fail without the change — 5 of those on the fast compiler, 3 on the Linq one. 4009 unit tests and 127 F# tests on both target frameworks, none failing.
No issue is filed for this; I found it sweeping the compilers against interpreted evaluation.