Repository navigation
Fix CompileFast returning wrong values for member access on an interface converted to a struct - #554
Merged
Conversation
Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CompileFast returning wrong values for interface converted to struct
Fix CompileFast returning wrong values for member access on an interface converted to a struct
Oct 7, 2026
dadhi
marked this pull request as ready for review
October 7, 2026 21:22
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.
CompileFast()returned wrong results for((Start)x).Memberwhenxis an interface-typed value andStartis a struct. Depending on the member, it returned the struct itself,default, or a different member's value.Compile()and theobject→ struct case were correct.TryEmitConvertonly emittedunbox.anywhen the source type was exactlyobject(orEnum). For an interface source it fell through to the generic path, which left the boxed reference on the stack. The member access then treated that reference as a struct value or address.TryEmitConvertinFastExpressionCompiler.csnow also emitsunbox.anywhen the source is an interface that the target value type implements. Interface → class conversions still go throughcastclass.Issue553_*test inFastExpressionCompiler.IssueTests, compiled into the LightExpression variant too. It covers a string property, an int property, a field and a method call on(Start)interface. Both variants are registered inTestsRunner/Program.cs.The fix only covers interfaces. Other non-value source types that a struct can convert from, such as
ValueType, are not touched here.