Fix Array<Interface> callfunc argument false-positive across component scopes - #1817
Merged
markwpearce merged 1 commit intoSep 11, 2026
Merged
Conversation
…t scopes Resolves rokucommunity#1816. Calling a component function via @ callfunc with an Array<MyItem> argument was rejected as incompatible with its own declared parameter type whenever the interface was imported into two different component scopes and the callfunc target was typed as a specific generated node type (e.g. roSGNodeA) rather than the generic roSGNode. Root cause: ReferenceType's isTypeCompatible falls back to comparing two same-named reference types by requiring their tableProvider closures to be reference-identical. Two independently-resolved references to the same underlying .bs interface (one from the declaring component's scope, one from the calling component's scope) never share that closure, even though they resolve to the same declaration -- so the check spuriously failed. Now, when two same-named references can't be verified as identical (only because they were built from different scopes) but the names match, treat them as compatible instead of rejecting -- consistent with the "can't resolve, assume compatible" fallback already used elsewhere in this file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
markwpearce
approved these changes
Sep 11, 2026
TwitchBronBron
approved these changes
Sep 11, 2026
Collaborator
|
Thanks for contributing! |
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
Fixes #1816. Calling a component function through
@callfunc with anArray<MyItem>argument was rejected as incompatible with its own declared parameter type whenever the interface was imported into two different component scopes and the callfunc target was typed as a specific generated node type (e.g.roSGNodeA) rather than genericroSGNode.Root cause
ReferenceType.isTypeCompatiblehas a fallback for comparing two same-named reference types that requires theirtableProviderclosures to be reference-identical. Two independently-resolved references to the same.bsinterface (one from the declaring component's scope, one from the calling component's own scope) never share that closure, even though both resolve to the same declaration -- causing a spurious mismatch.This only surfaces for arrays because
ArrayType.defaultTypepermanently memoizes its element type on first access, and for a callfunc target that first access happens once against a shared, globalComponentTypebuilt while the declaring component's scope is transiently linked. By the time a different calling scope validates its own call, that cached reference can no longer live-resolve. A scalar param re-resolves fresh each time instead of being cached, so it self-heals.Fix
When two same-named references can't be proven identical only because they came from different scopes, treat them as compatible -- matching the "can't resolve, assume compatible" fallback already used elsewhere in this file.
Test plan
roSGNodeAcallfunc target) -- zero diagnostics now.Array<integer>vsArray<MyItem>) is still flagged.npx mocha: 4561 passing (2 new), 9 pending, 0 failing.npm run lint: 0 errors.npm run build: succeeds.bsc --project bsconfig.json.