Repository navigation
Generic callback T no longer takes in the closure's captures (intermittent tslang crash) - #764
Merged
Merged
Conversation
An arrow that reads `this`, given to a generic function in a class method (`this.particles.filter((p) => p.d > this.lifetime)`), is rebuilt while the method's return type is discovered, and its type then has the captures ahead of its parameters. Inference dropped that input only when the arrow was already bound (#738), not on this first pass, where it is still a bare generic reference: `T` became `Element | captures`. With the element's class declared later in the file that failed every time ("cast from array type ... to array type '!ts.array<!ts.union<..., !ts.ref<!ts.tuple<{"this",...'"); with the default library's Array.filter the union's members came in an order of their types' addresses, and when the captures came first the arrow's parameter was taken for them: tslang crashed (0xC0000005; "Invalid index!" in a debug build) in about one run in four on native_ts_graphics' core/ray_tracing_extended_scene.ts, and pre-alpha111's own build too. The type helper now says whether the type it built has captures first, and inference drops them in either case. Test: tests/00generic_callback_closure_late_class.ts (gc, and rc/none through the corpus). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dress hash_value of the location's StringAttr hashes the attribute's storage, so an arrow's name (`..afL89C49FH<hash>`) was different in every run. It is now xxh3 of the file name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…romise check) The llvm dialect promises a DialectInlinerInterface that only registerAllDialects provides. A debug (assertions) tslang ended every --emit=jit with "checking for an interface (`mlir::DialectInlinerInterface`) that was promised by dialect 'llvm' but never implemented". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g_gc) too 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.
A generic callback's
Ttook in the closure's captures (a 1-in-4 tslang crash)this.particles.filter((particle) => ... this.lifetime)in a class method: while the method's return type is discovered, the arrow's type is rebuilt with its captures as its first input. Inference dropped that input only for an arrow already bound (#738), not on this first pass, where it is still a bare generic reference, soTbecameFlameParticle | captures. The union's members are ordered by their types' addresses: when the captures came first the arrow's parameter was taken for them, and tslang crashed (0xC0000005; "Invalid index!" inmlirGenFunctionParamsin a debug build) in about one run in four on native_ts_graphics'core/ray_tracing_extended_scene.ts— which broke its default build at random. pre-alpha111 built locally crashes too; its release binary happened not to.instantiateSpecializedFunctionTypeHelpernow reports whether the type it built has captures first, and inference drops them in either case. Scene file: 0/30 crashes (was ~8/30).Test:
tests/00generic_callback_closure_late_class.ts— its own generickeep<T>, the element class declared later in the file, which makes the bug deterministic (pre-alpha112: "cast from array type ... to array type '!ts.array<!ts.union<..., !ts.ref<!ts.tuple<{"this",...'"). gc, and rc/none through the corpus.Also
StringAttr's storage address:..afL89C49FH<hash>was different in every run.LLVM::registerInlinerInterfaceincreateMLIRContext: a debug tslang ended every--emit=jitwith "checking for an interface (mlir::DialectInlinerInterface) that was promised by dialect 'llvm' but never implemented"..gitignore:__jit*/(the debug JIT cache folder too).Found, not fixed (pre-alpha112 has them too), each with a class declared later in the file than its use:
arr.filter(arrow)(--no-default-lib): "the condition has no value";mainwhenmainalso callsassert(...): "Can't resolve property 'duration' of type any" (printof the same expression works).Release ctest: 6578/6578. native_ts_graphics default build with this compiler: complete;
basic_triangleruns, also under the JIT (release and debug tslang).🤖 Generated with Claude Code