Skip to content

Consult reference resolver for a call to an unresolvable identifier - #2750

Merged
lahma merged 1 commit into
sebastienros:mainfrom
poissoncorp:fix-2749-unresolvable-call
Jul 23, 2026
Merged

Consult reference resolver for a call to an unresolvable identifier#2750
lahma merged 1 commit into
sebastienros:mainfrom
poissoncorp:fix-2749-unresolvable-call

Conversation

@poissoncorp

Copy link
Copy Markdown
Contributor

Summary

Consult the reference resolver for a call to an unresolvable identifier.

Details

Since #2266 the base of an unresolvable reference is the Reference.Unresolvable sentinel rather
than undefined. JintCallExpression only consulted a custom IReferenceResolver when
baseValue.IsNullOrUndefined(), so a call to an undefined name (base = sentinel) skipped the
resolver and hit (Environment) baseValue, throwing InvalidCastException. A read of the same name
still 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 fix
established. 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

  • Added a unit test in Jint.Tests (Runtime/NullPropagation.CanCallUnresolvableReference)
  • Ran dotnet test --configuration Release locally. NullPropagation passes on net10.0 and net472; the new test fails without the fix with the exact InvalidCastException
  • ECMAScript spec change. N/A
  • Interop change. N/A
  • Perf change. N/A

Breaking change?

No. It restores the pre-#2266 behavior for custom IReferenceResolver implementations and does not change the public API.

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

@lahma lahma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom IReferenceResolver not consulted for a call to an unresolvable identifier since 4.6 (InvalidCastException, regresses #1041)

2 participants