Consult reference resolver for a call to an unresolvable identifier - #2750
Merged
Merged
Conversation
Since sebastienros#2266 the base of an unresolvable reference is the Reference.Unresolvable sentinel rather than undefined, so JintCallExpression stopped consulting a custom IReferenceResolver for a call to an undefined name (the guard only checked IsNullOrUndefined) and cast the sentinel to an Environment, throwing InvalidCastException. Also consult the resolver for unresolvable references, restoring the null-propagation deviation added for sebastienros#1041. Fixes sebastienros#2749
This was referenced Jul 23, 2026
This was referenced Jul 28, 2026
26 tasks
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.
Summary
Consult the reference resolver for a call to an unresolvable identifier.
Details
Since #2266 the base of an unresolvable reference is the
Reference.Unresolvablesentinel ratherthan
undefined.JintCallExpressiononly consulted a customIReferenceResolverwhenbaseValue.IsNullOrUndefined(), so a call to an undefined name (base = sentinel) skipped theresolver and hit
(Environment) baseValue, throwingInvalidCastException. A read of the same namestill went through the resolver, so only calls were affected.
This extends the existing "null-propagation helper" deviation to also fire for unresolvable
references (
referenceRecord.IsUnresolvableReference), restoring the behavior the #1041 fixestablished. A call to an undefined name is now routed through the resolver (e.g. resolved via
TryGetCallable) instead of throwing a CLR cast exception.Linked issue
Fixes #2749
Test plan
Jint.Tests(Runtime/NullPropagation.CanCallUnresolvableReference)dotnet test --configuration Releaselocally.NullPropagationpasses on net10.0 and net472; the new test fails without the fix with the exactInvalidCastExceptionBreaking change?
No. It restores the pre-#2266 behavior for custom
IReferenceResolverimplementations and does not change the public API.