Repository navigation
fix(ir): validate casts and emit unambiguous quoted IR - #240
Merged
LunaStev merged 1 commit intoOct 7, 2026
Merged
Conversation
3 tasks
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.
Problem and resulting behavior
A Bool value falsely annotated as an f64 cast source previously passed verification, as did checked i32 arithmetic using Bool operands. Printed IR also omitted parameter/block definition IDs while references used numeric IDs, making repeated friendly block names ambiguous. Raw names and control characters could split printed records.
This change rejects malformed conversions and checked operands, and emits typed IR format 3 with explicit identities and consistently quoted strings. AST JSON remains format 2 and semantics version remains 1.
Closes #109
Closes #52
Closes #53
Verification
InvalidCastrecords the result ID, opcode and source/destination types.fext/ftrunc. Integer bit operations may change signedness.tuple<T, bool>results. Add regression coverage for existing tuple extraction checks: tuple category, field bounds and exact field/result type.Textual IR format 3
Function/global definitions and references use
@fN/@gN; parameters and instructions define%vN; block definitions, branch/switch targets and phi predecessors use%bN. The printer preserves the supplied IDs and physical order, and explicitly records each function'sentry %bN. Value and block IDs are scoped to their containing function. Friendly names are quoted annotations, so duplicate block names and equal names in the function/global namespaces do not confuse references.For example:
This is a syntax fragment; the full verified multi-function fixture is
ir/tests/fixtures/text-identities-v3.wir.All target/name/link-name/constant-declaration/trap string fields use the same quoting function. It escapes quote, backslash, LF, CR, tab, NUL, other Unicode control characters and U+2028/U+2029; printable Unicode is preserved. No Rust Debug-dependent spelling remains in string records.
The AST-call golden output is renamed to
calls-v3.wir; existing printer assertions and the README are updated. LF fixture normalization remains enforced for Windows checkouts.Validation
-D warningspassed.Boundaries and follow-up
These are structural verification and printing changes. They do not implement numeric execution, runtime conversion traps, pointer metadata, a text parser or full text round trips. The arithmetic wrap/trap contract is unchanged. #89, #67 and #83 remain separate work.
The audit also reproduced and filed public-IR-API stack overflows as #238 (type/signature validation) and #239 (constant expression evaluation). Those issues remain open and are not claimed as fixed here.
Official reference updates across all nine existing Whale documentation languages are submitted separately to wave-platform, with complete IR/Rust examples, permitted/rejected conversion shapes, the new ID/escape syntax and format migration guidance.