fix: Hermes withPrefixKey crash and Turbopack static this in scope.module - #1674
Merged
Merged
Conversation
…module Hermes doesn't honor Symbol.species, so Array.prototype.map on a Disjoint returns a plain Array. invert() already rebuilt a Disjoint in that case (#1027); withPrefixKey() just cast the result, so unions of objects disjoint at a key crashed on Expo/React Native when a later Disjoint method was called on it. It now uses the same workaround (#1645). InternalScope.module referenced `this` inside a static arrow field, which Turbopack's transform can compile to an undefined module-level binding. It now calls InternalScope.scope directly (#1643). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — verified both Hermes/Turbopack compatibility fixes and the accompanying regression test.
Disjoint.withPrefixKeyHermes workaround — rebuilds aDisjointvianew Disjoint(...result)whenmapreturns a plainArray, mirroring the existinginvertguard. The removedas Disjointcast is correctly replaced by a truthfulas DisjointEntry[]; theinstanceofcheck then narrows back toDisjoint. On standard engines the behavior is unchanged.InternalScope.modulestaticthisremoval —this.scopeis nowInternalScope.scope. The oldthisresolved identically for every live caller (InternalScope.module, the re-exportedScopealias inark/type/keywords/*, and the detached$.constructor.moduleattached toParser), so this is behavior-preserving while removing the Turbopack static-binding hazard.- Regression test — overrides
Symbol.speciestoArrayand asserts bothwithPrefixKey(...)andinvert()returnDisjointinstances. I reverted thewithPrefixKeyguard locally and confirmed the test fails (false !== trueatunion.test.ts:112), so it pins the actual bug rather than passing vacuously.
Other Disjoint methods that use map (describeReasons) only call .join, so they don't depend on subclass preservation and need no equivalent guard — coverage here is complete.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
4 tasks done
ssalbdivad
added a commit
that referenced
this pull request
Oct 1, 2026
Bumps all publishable packages and documents the changes merged since 2.2.6: - fix `this[]` in self-referential object types (#1618, fixes #1406, @yharaskrik) - parse string.date.epoch.parse input as milliseconds (#1669, @breken-ai) - keep uppercase UUIDs valid in string.uuid JSON Schema (#1670, @breken-ai) - render nested bigints correctly in error messages (#1626, fixes #1477, @chatman-media) - release unused parse ids from the global registry (#1673, fixes #1584 for equivalent types, @isaacwasserman) - fix crashes on Hermes and Turbopack (#1674, fixes #1645 and #1643) #1590 only adds tests, so it has no changelog entry. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

Closes #1645
Closes #1643
Disjoint.withPrefixKeynow rebuilds aDisjointwhenmapreturns a plainArray, the same Hermes workaroundinvertalready had (Unable to use ArkType with Expo #1027). A test simulates Hermes by overridingSymbol.species.InternalScope.modulecallsInternalScope.scopeinstead ofthis.scope, which Turbopack can compile to an undefined binding.Lint, build and
testRepoWithVersionsAndBenchespass locally.🤖 Generated with Claude Code