Fix InvalidProgramException when NewArray result is ignored - #551
Open
exyi wants to merge 1 commit into
Open
Conversation
dadhi
requested changes
Aug 4, 2026
| var lambda = Lambda<Action>(array); | ||
|
|
||
| lambda.CompileSys()(); | ||
| lambda.CompileFast(true)(); |
Owner
There was a problem hiding this comment.
There should be at least calling of compiled delegates to verify there is no InvalidSomething.. exceptions.
And possibly assert the op codes produced match the expectations.
The same for the test below.
Contributor
Author
There was a problem hiding this comment.
It did call the compiled delegate, these two tests are two minimized repros of my failed expressions :).
I added the AssertOpCodes call
This should also fix more subtle problems with i.e. by-reference targets of the array assignment, since NewArray propagated ParentFlags Fix is to stop propagating parent flags + handle IgnoreResult. Same logic as my fix in 62bde56 Alternative is to propagate IgnoreResult and then don't create the array. However, array creation asserts that integer is positive, so this is invalid optimization, plus the case is quite patological and IMHO not worth optimizing for. AI use: I let AI generate the tests (before I applied the fix) + for code review of the fix.
exyi
force-pushed
the
fix-array-ignored-result
branch
from
August 4, 2026 22:00
6a335ad to
9b28726
Compare
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.
This should also fix more subtle problems with i.e. by-reference targets of the array assignment, since NewArray propagated ParentFlags
Fix is to stop propagating parent flags + handle IgnoreResult. Same logic as my fix in 62bde56
Alternative is to propagate IgnoreResult and then don't create the array. However, array creation asserts that integer is positive, so this is invalid optimization, plus the case is quite patological and IMHO not worth optimizing for.
AI use: I let AI generate the tests (before I applied the fix) + for code review of the fix.