Repository navigation
Throw an f32 as a float; fix three casts to f32 - #350
Merged
Merged
Conversation
A thrown f32 described itself as a double - the `.N` records with size 8 on Windows, `_ZTId` on Linux - so `catch (e: number)` took it and read eight bytes of a four-byte value (1.5f came back as 0.125), and a module throwing both kept whichever box thunk it built first. It is now a C++ float (`.M` / `_ZTIf`): typed and untyped catches read it, and a `number` catch takes it through a widening entry, as it does an int (Windows: a `.N` copy thunk; Linux: an extra clause plus fpext when binding). Also fixes the inverted NUMBER_F64 branch in LLVMRTTIHelperVCWin32::setType, harmless until f32 got names of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`<f32>e` in an untyped catch - and any `<f32>` of an `any` - failed to compile: `___unbox<f32>` tries every boxed type, and three of its casts were bad. - boolean -> f32 had no lowering (only boolean -> number did) and became undef with an "invalid cast" warning; it is now a uitofp. - index -> f32 went through index.casts, which only make integers, and lowered to a trunc to f32 that the verifier rejects; a float now takes the sitofp that index -> number always used. - string -> f32 returned atof's double as the float; ParseFloat now truncates to its result type. 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.
Summary
float, not a double. A thrown f32 described itself as a double: on Windows it used the.Nrecords with size 8, on Linux_ZTId. Socatch (e: number)took it and read eight bytes of a four-byte value (1.5f came back as 0.125). A module that threw both an f32 and a double also kept whichever box thunk it built first. The f32 is now.M/_ZTIf. Typed and untyped catches read it, and anumbercatch takes it through a widening entry, the same way it takes an int:.Ncopy thunk.NUMBER_F64branch inLLVMRTTIHelperVCWin32::setType. It was harmless until f32 got names of its own.<f32>of ananyfailed to compile, including<f32>ein an untyped catch, because___unbox<f32>tries every boxed type:uitofp.index.casts, which only produce integers, and lowered to an invalidtrunc. It now uses thesitofpthat index -> number already used.ParseFloatnow truncates to its result type.Tests
00throw_f32.ts,00cast_to_f32.ts(compile, jit, and the rc/none corpus runs).🤖 Generated with Claude Code