Repository navigation
EH fixes: interface-field accessors in try, a call in a catch to a typed catch, uncaught descriptions; ++/-- on accessors - #732
Merged
Conversation
…atch can throw to a typed catch - A load or a store through an interface's field whose slot names a cell of accessors calls the getter or setter only once it is lowered to LLVM, after the `try`. Such an access inside a `try` now ends its block with a ts.AccessorUnwindEdge to the handler (added once the function is one CFG), which keeps the landing block and lowers to a branch. The getter or setter is called by an invoke unwinding there. - On Windows a print of several values was a variable-size alloca. In a function with exception funclets it moved the stack, and an exception thrown by a call in a catch, taken by a typed catch of the same function, had its catch object written at the wrong address: a crash, or a stack overflow. There the line is now built on the heap and freed once written; so is it in a presplit coroutine, where the heap copy leaked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`o.prop++` was an error ("'++'/'--' on a get/set accessor property is not
supported"): there is no reference to store the new value to. MLIRGen now
calls the setter with the getter's value plus or minus one, as `+= 1` does,
and gives the new value for a prefix operator and the old one for a postfix.
This covers instance, static, virtual, `this.`, interface and object-literal
accessors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A JIT run that ended in an uncaught exception printed only "uncaught exception". Since the range checks throw a RangeError (#731), that lost the message their asserts printed. The JIT's exception filter now reads the thrown value while it is still alive, from the record of the throw: a string, a number, a boolean or a bigint by its value, a class by its name, and an Error (core.ts) by its name and message: tslang: error: uncaught exception: RangeError: Division by zero Every read is guarded; a record of another shape is left undescribed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Oct 29, 2026
…parameter functions as wider function types (#733) * A finally that throws while an exception unwinds replaces it (Windows) On Windows the finally run on the way out of an exception was a cleanup funclet, which may not throw: a call or a throw there was a second exception during unwinding, and the process terminated. A finally that may throw is now entered through the catch-all pad a `return` in it already used, which rethrows at its end; thrown from it, an exception is a nested one, which replaces the first, as JavaScript's does. The copy of the finally on that path also lost its calls' unwind entries (cloneRegionBefore carried over jumps and parentTryOp only): a call there was a plain call, which in the funclet has no way out, and -O3 crashed on it. Its unwind entries, and the interface-field accesses of #732, are carried over now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A function with fewer parameters can be given as a wider function type `apply(one)` where `apply` takes `(a: number, b: number) => number` and `one` takes `a` only was an error ("it takes 1 argument(s), 2 expected"), though TypeScript lets a function ignore the parameters it does not declare. A named function or an arrow that captures nothing is now given as a private function of its own (`<name>.args<N>`) that takes them all and calls it with the first ones. No result and a `void` one count as the same. A closure is still an error: its wrapper would have to carry the captures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- 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.
Two exception-handling fixes, plus
++/--on accessors, and uncaught exceptions that say what was thrown.An interface-field accessor that throws inside
tryis caughtThis was the gap left open by #731.
A class can fill an interface's field with a getter and setter, through a tagged cell (#719). A load or store through that field calls the accessor only when it is lowered to LLVM, which happens after
tryhas been lowered. So a throw from the accessor escaped thecatch.The ownership passes (the verifier, inference and stack promotion) run between
trylowering and LLVM lowering, and they analyze these loads and stores. So the loads and stores stay as they are:trylowering records each load or store through such a field (mayCallInterfaceAccessor, sharing the predicate withInterfaceAccessorCell::of).ts.AccessorUnwindEdge [^cont, ^landing]. This keeps the landing block alive, since it may have no other predecessor, and shows the analyses that the access may leave for the handler.invokethat unwinds to the landing block.A call in a
catchcan throw to a typedcatchin the same functionThis was a crash, an
abortin the built executable, or a stack overflow:printwith several values builds its line in a variable-sizealloca. In a function with exception funclets, that moves the stack, and the CRT then writes the outer catch's object to the wrong address. Building the IR with clang's own backend reproduced it, and removing theallocaalone fixed it.++and--on a get/set propertyo.prop++was an error: "'++'/'--' on a get/set accessor property is not supported". It now calls the setter with the getter's value plus or minus one, the same as+= 1does. A prefix operator gives the new value, and a postfix operator gives the old one. It works for instance, static, virtual,this., interface and object-literal accessors. The new test is00class_accessor_increment.ts.An uncaught exception says what was thrown
In the JIT, an uncaught exception used to print only "uncaught exception". Since #731 made the range checks throw a
RangeError, that meant losing the message their asserts used to print. The JIT's exception filter now reads the thrown value from the throw's exception record while the value is still alive:Erroris printed by its name and message, for exampletslang: error: uncaught exception: RangeError: Division by zero.Every read is guarded, and a record of any other shape is left undescribed. The
uncaught/*tests now check this text, andthrow_number.tsis new. This applies to Windows only, where the JIT catches the exception; executables built ahead of time still end without a message.Still open
A call that throws inside a
finallywhile another exception is unwinding still ends the program. The C++ runtime treats that asterminate, and Windows cleanup funclets can't throw.Tests
00try_catch_accessor.tsnow also covers interface-field get and set,finally, and a plain-field implementer.00try_catch_call_in_catch.tscovers catch values of number, class and string types, and afinallyon the way out.🤖 Generated with Claude Code