Skip to content

test(native): cover an inherited cycle reached from two branches, and the compiler's cut - #422

Merged
danstepanov merged 2 commits into
nativewind:mainfrom
YevheniiKotyrlo:fix/variable-resolution-cycle
Dec 2, 2026
Merged

danstepanov merged 2 commits into
nativewind:mainfrom
YevheniiKotyrlo:fix/variable-resolution-cycle

Conversation

@YevheniiKotyrlo

@YevheniiKotyrlo YevheniiKotyrlo commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

main's cycle tests declare every cycle on the element that reads it. Two cases #451 cuts are left uncovered:

  • One variable reached again from two branches of one value, declared on an ancestor and read on a descendant. Chromium 153, Firefox 155 and WebKit 26.6 drop the whole reading declaration rather than keep a partial value, while an unrelated variable still resolves.
  • A cycle in a variable declared once on the reading element, which the compile-time inliner cuts before the runtime sees it.

Tests

src/__tests__/native/variable-cycles.test.tsx gains those two cases.

Verification

A local replica of CI passes every job on Node 26.12.1, where .nvmrc pins 24.22.3: lint and typecheck, yarn test --maxWorkers=2 --coverage (2238 passed), the library build with node --test, the web export and commitlint in Ubuntu, and the iOS dev build on macOS with Xcode 27.2, where ci.yml pins 26.6.

@YevheniiKotyrlo

YevheniiKotyrlo commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor Author

No device frame

This PR adds tests only. main already cuts a variable cycle (#451), so a device renders the same with and without it.

@YevheniiKotyrlo
YevheniiKotyrlo force-pushed the fix/variable-resolution-cycle branch from 3ab7d96 to f5913ae Compare October 11, 2026 12:35

@sammoore sammoore left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Appreciate keeping this open. From what I can tell, I think our existing tests cover these cases, with the exception of:

  • "a cycle in a variable declared once is cut by the compiler"
  • "one variable reached again from two branches of one value, inherited, drops the reading declaration"

Can we just keep those?

@YevheniiKotyrlo YevheniiKotyrlo changed the title fix(native): cut circular variable resolution instead of blowing the stack test(native): cover an inherited cycle reached from two branches, and the compiler's cut Dec 2, 2026
@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor Author

Trimmed to those two: "a cycle in a variable declared once is cut by the compiler" and "one variable reached again from two branches of one value, inherited, drops the reading declaration".

@sammoore sammoore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this!! LGTM.

…er's guard

nativewind#451 cuts a custom-property cycle at runtime and in the compile-time
inliner, and tests cycles declared on one element. A variable reaches a
descendant unresolved, so a cycle can also close on the element that reads
it: a variable that is itself, one reached again through a fallback, two that
name each other, and one reached from two branches of one value. Each drops
the declaration that reads it, as browsers do, while an unrelated variable
still resolves.

The other cases pin what must not read as a cycle: a variable read twice in
one declaration, and a long inherited chain. The compiler cases pin that the
inliner leaves a cycle for the runtime and still folds a chain.
main's tests already cover the other cases, so the branch keeps an
inherited cycle reached from two branches of one value and a cycle in a
variable declared once, which the compiler cuts.
@danstepanov
danstepanov force-pushed the fix/variable-resolution-cycle branch from 0d6421f to 537c1fa Compare December 2, 2026 17:59
@danstepanov
danstepanov merged commit 77a047a into nativewind:main Dec 2, 2026
6 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.

3 participants