Repository navigation
TypeId: the counter starts lazily, without __init__ - #25
Merged
Merged
Conversation
TypeIds are made by other classes' static initializers (factories' `TYPE`s), and Haxe documents no order between those and TypeId's own static initialization. Under hxmc, `__init__` ran after the statics of classes reached earlier: it reset the counter, later ids repeated earlier ones, and the differ took one node type for another (a native view for an empty node: "invalid cast" in RNativeBase.update). The counter is now null until the first id is taken, which holds whatever the order. TypeIds are made once per node type, so the test costs nothing. Co-Authored-By: Claude Opus 5.5 <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.
TypeId's counter was reset to 0 in__init__. TypeIds are made by other classes' static initializers (every factory'sTYPE,VEmpty.TYPE, ...), so this relies on every__init__running before every static initializer. JS and HL generate it that way, but Haxe doesn't document it.hxmc runs an
__init__after the statics of classes it reached earlier. Three modules reproduce it:A.TYPE,B.TYPE, then a third id0, 1, 20, 1, 0(the reset came after A and B)In coconut.appkit (native AppKit views) the repeated ids made the differ take a native view's node type for the empty node's, which ended in
invalid castinRNativeBase.updatewhen a<Box>was replaced bynull.The change: the counter is
Null<Int>, null until the first id is taken. There's no__init__and no initializer, so the result doesn't depend on initialization order. On JS an untouched static isundefined, which== null. TypeIds are made once per node type (in statics), so the extra test costs nothing.Tested:
0, 1, 2on JS (node) and on hxmc, with another class's static taking the first one.Not tested: the repo's own tests. Its pinned Haxe 4.2.1 is an x86 binary this Mac can't run, and the pinned tink_core 2.0.2 doesn't compile under 4.3.7 ("Recursive implicit cast" in
Promise.hx), unrelated to this change.The
v1branch has the sameTypeId. I can port this there too.🤖 Generated with Claude Code