Commit 920ec13
Partial hardening for discovery-pass tolerance during nested object-literal method resolution
Investigates the "chained sibling-method return" gap found while extending
test coverage (a value-returning method can't `return this.sibling(...)` or
`let x = this.sibling(...)` within the same object literal, even though a
bare-statement call to the same sibling works fine).
Root-caused via --debug-only=mlir tracing: an enclosing function with no
explicit return type runs a speculative discovery pass (dummyRun=true,
allowPartialResolve=true) that recurses into any nested object literal's
methods. A method's prototype is only registered into the literal's
(mutable) storage type AFTER its own discovery completes, so an
earlier-declared sibling can still be missing from `this`'s type when a
later method's body is walked for captured-variable/return-type discovery,
regardless of source order.
Fixes two of the (at least three) layers this surfaces, both using the same
dummyRun/allowPartialResolve tolerance idiom already established elsewhere
in both files (mlirGenCallExpression's existing
`!result.value && genContext.allowPartialResolve` case):
- mlirGenPropertyAccessExpressionBaseLogic (MLIRGenAccessCall.cpp): the
"Can't resolve property" error now returns mlir::success() (no value)
instead of hard-failing during a dummy/partial-resolve run.
- discoverFunctionReturnTypeAndCapturedVars (MLIRGenFunctions.cpp): the
"'return' is not found" error is skipped (still returns mlir::failure()
to signal non-convergence, but without emitting a diagnostic) when the
OUTER context is itself a dummy/partial-resolve run.
NOT a complete fix - the original repro still fails, now with a bare
"failed statement" and no specific diagnostic. A third, more fundamental
layer remains: mlir::failure() without an emitted error still propagates as
a hard abort through ordinary sequential statement processing, so the
nested discovery's now-silent non-convergence still aborts the whole
enclosing function's discovery via a statement (`let calc = {...}`)
entirely unrelated to that function's own return type. Full mechanism and
the remaining gap are documented in
docs/interface-vtable-simplification-design.md for whoever picks this up
next - it's not yet known how many more call sites need the same
tolerance, and each layer found so far needed a separately-targeted fix.
Both changes verified individually and together to cause zero change in
behavior for the existing suite: 730/730 passed, unchanged. No regression
test added (the repro this was investigating is still broken).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 5e995d7 commit 920ec13
3 files changed
Lines changed: 115 additions & 6 deletions
File tree
- tslang
- docs
- lib/TypeScript
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 527 | + | |
531 | 528 | | |
532 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
384 | 399 | | |
385 | 400 | | |
386 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
| 448 | + | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
453 | 469 | | |
454 | 470 | | |
455 | 471 | | |
| |||
0 commit comments