Repository navigation
Fix five compiler bugs found during audit - #8
Merged
Merged
Conversation
- list_access hardcoded field indices 0/1 instead of looking up len/data
dynamically, breaking if the List struct reorders its fields. Extract
Program::list_field_indices helper (DRY with list_lit and codegen).
- Integer literals > i128::MAX silently wrapped via `as i128`; negation
of large literals could overflow. Use try_from / checked_neg and emit
a proper diagnostic.
- Exhaustiveness checker treated any list pattern as complete coverage,
so `match xs { [a] -> ... }` would not warn about missing lengths.
Now each generated constructor (exact lengths + the at-least tail)
must actually appear in the used set.
- Unnecessary .clone().iter() inside unify for Tuple and Adt arms;
bind the clone to a local so the intent is clear.
- F32 had to_bits but no from_bits; add the symmetric constructor.
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
len/datafields instead of dynamic lookup — would silently produce wrong bounds checks and array accesses if the List struct reorders its fields. ExtractedProgram::list_field_indices(DRY withlist_litand codegen).i128::MAXsilently wrapped; negation could overflow. Now emits a proper diagnostic.match xs { [a] -> ... }would not warn about uncovered lengths (0, 2, 3, …).unify:x.clone().iter()on Tuple/Adt arms bound to locals for clarity.F32.from_bits:F32hadto_bitsbut no symmetric constructor.Test plan
cargo buildcleancargo test— 0 failures)