Skip to content

Fix Array<Interface> callfunc argument false-positive across component scopes - #1817

Merged
markwpearce merged 1 commit into
rokucommunity:v1from
TacoJr01:fix-array-interface-scope-compat
Sep 11, 2026
Merged

markwpearce merged 1 commit into
rokucommunity:v1from
TacoJr01:fix-array-interface-scope-compat

Conversation

@TacoJr01

Copy link
Copy Markdown

Summary

Fixes #1816. Calling a component function through @ 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 generic roSGNode.

Root cause

ReferenceType.isTypeCompatible has a fallback for comparing two same-named reference types that requires their tableProvider closures to be reference-identical. Two independently-resolved references to the same .bs interface (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.defaultType permanently memoizes its element type on first access, and for a callfunc target that first access happens once against a shared, global ComponentType built 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

  • Added a test reproducing the issue (two components, shared imported interface, array param, roSGNodeA callfunc target) -- zero diagnostics now.
  • Added a negative-case test confirming a genuinely incompatible array arg (Array<integer> vs Array<MyItem>) is still flagged.
  • npx mocha: 4561 passing (2 new), 9 pending, 0 failing.
  • npm run lint: 0 errors. npm run build: succeeds.
  • Manually verified against the issue's exact repro with bsc --project bsconfig.json.

…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

Copy link
Copy Markdown
Collaborator

Thanks for contributing!

@markwpearce
markwpearce merged commit f86818d into rokucommunity:v1 Sep 11, 2026
9 checks passed
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.

4 participants