Skip to content

Fix five compiler bugs found during audit - #8

Merged
lemonhub-io merged 2 commits into
puddi-lang:mainfrom
loreste:fix/compiler-bugs
Nov 23, 2026
Merged

lemonhub-io merged 2 commits into
puddi-lang:mainfrom
loreste:fix/compiler-bugs

Conversation

@loreste

@loreste loreste commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • list_access field order bug: hardcoded indices 0/1 for List's len/data fields instead of dynamic lookup — would silently produce wrong bounds checks and array accesses if the List struct reorders its fields. Extracted Program::list_field_indices (DRY with list_lit and codegen).
  • u128→i128 truncation: integer literals larger than i128::MAX silently wrapped; negation could overflow. Now emits a proper diagnostic.
  • Exhaustiveness false positive for lists: any list pattern made the checker report "complete", so match xs { [a] -> ... } would not warn about uncovered lengths (0, 2, 3, …).
  • Unnecessary clones in unify: x.clone().iter() on Tuple/Adt arms bound to locals for clarity.
  • Missing F32.from_bits: F32 had to_bits but no symmetric constructor.

Test plan

  • cargo build clean
  • All 160 conformance tests pass
  • All integration tests pass (cargo test — 0 failures)

- 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.
@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Nov 23, 2026
@lemonhub-io
lemonhub-io merged commit 81aeb2e into puddi-lang:main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants