The delegate-conversion tests all miss the instance-keyed cache - #3566
Merged
lahma merged 1 commit intoSep 1, 2026
Merged
Conversation
…eparation tests cannot reach `HostDelegateConversionTests` covers sebastienros#3434 through three shapes, and all three give each engine a function of its own. That exercises the AST-keyed cache — the cross-engine half — and leaves the instance-keyed one untested: no test asks a single function *instance* for two different delegate types, which is the case the outer `ConditionalWeakTable<object, TypeKeyedCache<Delegate>>` exists to answer. Measured rather than assumed. Keying only that lane on a constant, so the instance cache is un-keyed while the AST cache stays keyed by target type, leaves all three existing tests green and fails nothing: Passed: 3, Failed: 0 The test added here fails under exactly that mutation, with the defect's own message — `ArgumentException: Object of type 'Notify' cannot be converted to type 'Transform'` — so a future simplification that folds the instance lane back to a plain weak table now has something that notices. Test-only; no production change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014W5mbjGhyvgAS4pivXoc4S
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.
#3521 keyed both delegate caches by the target type.
HostDelegateConversionTestspins it through three shapes — two engines on onePrepared<Script>, the same in the other order, and the two alternating — and every one of them gives each engine a function of its own.That means all three exercise the AST-keyed cache. None exercises the instance-keyed one: no test asks a single function instance for two different delegate types, which is the entire reason the outer
ConditionalWeakTable<object, TypeKeyedCache<Delegate>>carries aTypeKeyedCacherather than a bareDelegate.The gap, measured
Keying only the instance lane on a constant — so it behaves as it did before #3521 while the AST lane stays keyed by target type:
All three existing tests stay green. A simplification that folded the instance lane back to a plain weak table would have landed unnoticed.
The test added here fails under exactly that mutation, with the defect's own message:
and passes on
mainas it stands. It also converts back to the first type afterwards, so it says the two entries coexist rather than evict each other.Test-only; no production change. Found while auditing process-wide caches for #3426 — I had an equivalent local fix and test predating #3521, and this is the only part of it
maindid not already have.Verification
Jint.Tests.PublicInterfaceHostDelegateConversionTests: 4/0 on net472, net8.0 and net10.0.🤖 Generated with Claude Code
https://claude.ai/code/session_014W5mbjGhyvgAS4pivXoc4S