Skip to content

feat: integer width support (u8-u248, i8-i248)#70

Merged
brockelmore merged 1 commit intomainfrom
brock/integer-widths
Mar 11, 2026
Merged

feat: integer width support (u8-u248, i8-i248)#70
brockelmore merged 1 commit intomainfrom
brock/integer-widths

Conversation

@brockelmore
Copy link
Copy Markdown
Collaborator

Summary

  • Add sub-256-bit integer types (u8-u248, i8-i248) with full checked arithmetic, compile-time overflow detection, and type safety
  • Literal type suffixes (42u8, 0xffi16), cast syntax (expr as u8), signed opcode selection (SDIV, SMOD, SLT, SGT, SAR)
  • Mixed-width and signed/unsigned mismatch rejection with diagnostic suggesting explicit casts; unsuffixed literals adopt the type of the other operand
  • 72 new e2e tests covering checked arithmetic, overflow reverts, boundary cases, unsafe wrapping, casts, comparisons, negation, and compile-time error messages

Test plan

  • 385 e2e tests pass (0 failed, 1 ignored)
  • 38 IR unit tests pass
  • cargo +nightly fmt clean
  • just check-clippy-ci clean
  • Unsigned: u8 add/sub/mul overflow reverts, bitwise ops, division, truncation, chaining, literal suffixes, casts, boundary cases
  • Signed: i8 add/sub/mul overflow reverts, SDIV with positive/negative operands, unary negation, SLT/SGT comparisons, unsafe wrapping arithmetic
  • Compile-time: constant overflow rejected with span-preserving diagnostics, mixed-width rejected, signed/unsigned mismatch rejected
  • Unsuffixed literal type adoption (u8, i8, addr, bool)

🤖 Generated with Claude Code

…c and type safety

Add sub-256-bit integer types with full checked arithmetic, compile-time
overflow detection, mixed-width/signedness rejection, unsuffixed literal
type adoption, type casting, and signed opcode selection.

- Literal type suffixes (42u8, 0xffi16) through lexer→parser→AST→IR
- Cast syntax (expr as u8) with mask/sign-extend
- Width-checked add/sub/mul that reverts on overflow for sub-256-bit types
- Compile-time constant overflow detection with span-preserving diagnostics
- Post-egglog overflow detection for optimization-revealed cases
- Narrow-type-preserving egglog constant folding rules
- Mixed-width rejection (u8 + u256 → error suggesting explicit cast)
- Signed/unsigned mismatch rejection (i8 + u8 → error)
- Unsuffixed literals adopt the type of the other operand
- Signed opcodes (SDIV, SMOD, SLT, SGT, SAR) for IntT types
- Sign-extend for signed type truncation
- Paren expression type inference in infer_expr_type
- 72 new e2e tests (35 unsigned, 37 signed) covering checked arithmetic,
  overflow reverts, boundary cases, unsafe wrapping, casts, comparisons,
  negation, compile-time error messages, and mixed-width rejection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 10, 2026

Deploy Preview for edgelang ready!

Name Link
🔨 Latest commit 84f1971
🔍 Latest deploy log https://app.netlify.com/projects/edgelang/deploys/69b0a68eb3d9df0008af3591
😎 Deploy Preview https://deploy-preview-70--edgelang.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown

No gas changes detected.

@brockelmore brockelmore merged commit 12e76ba into main Mar 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant