Commit c25745e
Fix hybrid-func-to-func cast crash when casting cross-module tuple to interface
castTypeScriptTypes handled narrowing a BoundFunctionType value to a plain
FunctionType (the "losing this reference" vtable-slot path) but not the
equivalent HybridFunctionType case - the actual type of a method field read
off a cross-module reconstructed tuple. That value fell through to
castLLVMTypes' dead "value to ref of value" branch and hit
llvm_unreachable("review usage") at CastLogicHelper.h:765, crashing the
compiler on `<Counter>importedObj` in the importing module.
Add the missing branch, mirroring the BoundFunctionType case: extract the
raw function pointer via GetMethodOp and warn about the dropped receiver
(the interface vtable call re-supplies its own thisVal).
Note: this fixes the compile-time crash only. Verifying end-to-end surfaced
a separate pre-existing bug - the object clone built for the interface cast
writes its fields in reversed order, so the vtable's field offsets read the
wrong slots at runtime. Recorded in
docs/interface-vtable-simplification-design.md for a follow-up
investigation; no regression test added since the full scenario still fails
on that second bug.
Full ctest suite: 720/720 passed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent b11b684 commit c25745e
2 files changed
Lines changed: 47 additions & 0 deletions
File tree
- tslang
- docs
- include/TypeScript/LowerToLLVM
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
244 | 255 | | |
245 | 256 | | |
246 | 257 | | |
| |||
0 commit comments