Repository navigation
Throw and catch booleans and bigints; fix four bigint gaps and <boolean> unboxing - #348
Merged
Merged
Conversation
…an> unboxing
`throw true` and `throw 5n` were rejected ("Not supported type in throw"). A
boolean is now thrown as a C++ bool (`_N` / `_ZTIb`) and a bigint, an i64, as an
__int64 (`_J` / `_ZTIx`), each with the boxing entry the other primitives have
for an untyped catch (Windows copy thunk / Linux catch-all dispatch). A bigint
literal is a plain i64, so 64-bit integers map to the bigint entries too.
Bigint gaps found on the way, each reachable without exceptions:
- boxing a bigint into an `any` crashed the compiler: typeof had no name for it,
so BoxOp got a null type tag;
- unboxing one from a string failed to compile: ParseIntOp always used atoi/
strtol (32 bits), now atoll/strtoll for a 64-bit result;
- converting one to a string was a bare inttoptr, so print() of a bigint crashed;
- comparing two bigints was constant false (LogicOp had no case for them).
Also: `<boolean>` of an `any` failed to compile - createFConstantOf(32) built an
f64 zero, which the f32 branch of ___unbox<boolean> compared an f32 against.
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.
throw trueandthrow 5nwere rejected at compile time with "Not supported type in throw".Throw / catch
bool:_Non Windows,_ZTIbon Linux.i64, is thrown as an__int64:_Jon Windows,_ZTIxon Linux.i64, so 64-bit integers map to the bigint entries too.catch (e: boolean),catch (e: bigint)) and untyped catches both work. A catch that doesn't match passes the exception on to the next one.Bigint gaps found along the way (all reachable without exceptions)
anycrashed the compiler.typeOfAsStringhad no name for bigint, soBoxOpgot a null type tag.ParseIntOpalways usedatoi/strtol, which return 32 bits. It now usesatoll/strtollwhen the result is 64 bits. Plainstrtolis also 32 bits on Windows.print(x)of a bigint crashed. The conversion to string was a bareinttoptr, soputsreceived the value as an address.false, evenu == vfor equal values.LogicOphad no case for bigint and fell through to its "not applicable" constant. Comparing against a literal happened to work, because the literal carries its own integer type.Also
<boolean>of ananyfailed to compile.createFConstantOf(32, …)built anf64zero whenNUMBER_F64is set. Thef32branch of the generated___unbox<boolean>then compared anf32against thatf64.New test:
00throw_bool_bigint.ts, registered for compile, jit and the rc/none corpus.Verified locally
check-x86-eh.sh: 53/53.-mm=noneand-mm=gc.🤖 Generated with Claude Code