Repository navigation
Chapter 11: Long Integers - #20
Conversation
Cross-targeting & Mach-O: - main.rs/runner.rs: prepend `-arch x86_64` to `as`/`gcc` under #[cfg(target_arch = "aarch64")] so the external toolchain cross-targets x86-64 on Apple Silicon - emit_iced.rs: set LC_BUILD_VERSION (macOS 11.0) on Mach-O objects so `ld` stops warning about a missing platform load command CI (coverage.yml): - matrix over ubuntu-latest/macos-latest with per-OS codecov flags - install Rosetta on macOS; use taiki-e/install-action for cargo-llvm-cov Test runner (runner.rs): - parallelize by case via rayon (global pool bounds concurrency) - gate redundant --external-linker and per-test --no-iced runs to Linux; add one non-Linux --no-iced smoke test to keep the arm64 `as` shim covered - drop the manual result summary (printed once per test = twice); surface failures via the assertion message instead - Cargo.toml: rayon dev-dep; disable the empty bin test harness (test = false) Docs: fix wild linker URL (wild-linker/wild); macOS no longer Intel-only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @johnhringiv's task —— View job Pull Request ReviewI've completed a comprehensive review of this Chapter 11 implementation that adds Review Tasks
🟢 StrengthsExcellent Type System Design
Correct Arithmetic Semantics
Strong Platform Support
Performance Improvements
🟡 Areas for ImprovementRemaining Performance TODOs // src/validate.rs:533, 1205, 1427, 1448
// Still has some expensive HashMap clones per function/block
let mut inner_map = variable_map.clone(); // TODO: consider Arc/Rc approachThese are noted but acceptable for a learning project - could be optimized with Test Edge Cases
🟢 Code Quality AssessmentIdiomatic Rust
Error Handling
Testing
🟢 Security & CorrectnessNo Security Concerns
Correctness
🔧 Minor Suggestions
🎯 Overall AssessmentThis is high-quality, production-ready code for a learning compiler. The type system implementation is correct, the performance optimizations are meaningful, and the testing is comprehensive. The code follows Rust best practices and C semantics correctly. Recommendation: Approve ✅ The compound assignment bug fix and deterministic integer semantics make this a solid foundation for future features. The Apple Silicon CI support and parallel test runner are excellent quality-of-life improvements. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Claude finished @johnhringiv's task —— View job Pull Request ReviewI've completed a comprehensive review of this Chapter 11 implementation that adds Review Tasks
🟢 StrengthsExcellent Type System Design
Correct Arithmetic Semantics
Strong Platform Support
Performance Improvements
🟡 Areas for ImprovementRemaining Performance TODOs // src/validate.rs:533, 1205, 1427, 1448
// Still has some expensive HashMap clones per function/block
let mut inner_map = variable_map.clone(); // TODO: consider Arc/Rc approachThese are noted but acceptable for a learning project - could be optimized with Test Edge Cases
🟢 Code Quality AssessmentIdiomatic Rust
Error Handling
Testing
🟢 Security & CorrectnessNo Security Concerns
Correctness
🔧 Minor Suggestions
🎯 Overall AssessmentThis is high-quality, production-ready code for a learning compiler. The type system implementation is correct, the performance optimizations are meaningful, and the testing is comprehensive. The code follows Rust best practices and C semantics correctly. Recommendation: Approve ✅ The compound assignment bug fix and deterministic integer semantics make this a solid foundation for future features. The Apple Silicon CI support and parallel test runner are excellent quality-of-life improvements. |
The lint job cached ~/.cargo but not target/, so clippy recompiled all dependencies every run. Add target/ to its cache (matching coverage.yml). Give lint and coverage distinct cache keys (lint-/coverage-) so their artifacts don't collide — coverage builds with -C instrument-coverage, whose fingerprints differ from a plain clippy build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @johnhringiv's task —— View job Pull Request ReviewI've completed a comprehensive review of this Chapter 11 implementation that adds Review Tasks
🟢 StrengthsExcellent Type System Design
Correct Arithmetic Semantics
Strong Platform Support
Performance Improvements
Comprehensive Warning System
🟡 Areas for ImprovementRemaining Performance TODOs // src/validate.rs:591, 1492, 1697, 1720
// Still has some expensive HashMap clones per function/block
let mut inner_map = variable_map.clone(); // TODO: consider Arc/Rc approachThese are noted but acceptable for a learning project - could be optimized with Test Edge Cases
🟢 Code Quality AssessmentIdiomatic Rust
Error Handling
Testing
🟢 Security & CorrectnessNo Security Concerns
Correctness
🔧 Minor Suggestions
🎯 CI & Coverage AssessmentCI Status: ✅ The GitHub Actions are well-configured
Test Coverage: 91.46% patch coverage is strong
🎯 Overall AssessmentThis is high-quality, production-ready code for a learning compiler. The type system implementation is correct, the performance optimizations are meaningful, and the testing is comprehensive. The code follows Rust best practices and C semantics correctly. Recommendation: Approve ✅ The compound assignment bug fix and deterministic integer semantics make this a solid foundation for future features. The Apple Silicon CI support and parallel test runner are excellent quality-of-life improvements. |
Release Notes
Adds the
long(64-bit) integer type and the type system to support it, a suite ofconstant-expression warnings, plus pre-merge improvements: Apple Silicon (arm64) CI support
and a parallelized test runner.
New Features
Long Integer Type System
long(64-bit) signed integer type alongside the existingint(32-bit), and the type system that lets the two interoperateTypedExpression) produced by the type-checking pass; the symbol table now tracks each identifier's type(type) exprlongliterals via thel/Lsuffix; unsuffixed decimal literals too large forintpromote tolongper §6.4.4.1Deterministic Integer Semantics
int: 32-bit,long: 64-bit)long→intconversion truncates to the low 32 bits& 31forint,& 63forlong) to avoid UBCompile-Time Warnings (constant-expression diagnostics)
Five new warnings flag non-portable or undefined-in-standard-C constructs that NCC nonetheless compiles deterministically. Each is emitted through a single
warn_*helper, centralizing wording/format (matching the convention in CLAUDE.md):-Wdiv-by-zero: constant zero divisor in/,%,/=,%=(e.g.x / 0). A constant zero divisor in a constant-required context (static initializer, case label) is a hard error instead-Wshift-count-overflow/-Wshift-count-negative: constant shift count that is negative or>=the operand width (32 forint, 64 forlong), e.g.1 << 32,1 << -1-Woverflow: constant-folding a static initializer or case label overflows the result type (e.g.int x = 2147483647 + 1;)-Wconstant-conversion: a constant initializer is implicitly narrowed to a type that can't hold it (e.g.int x = 2147483648;); an explicit cast silences it-Wsequence-point: the same object is modified more than once between sequence points (e.g.i = i++,f(i++, i++)) — UB in standard C, but well-defined under NCC's left-to-right evaluationImprovements
--validatenow prints the typed AST (TypedProgramimplementsItfDisplay)Rc<str>and the typecheck pipeline now consumes the parser AST, turning ~150 expensive string/AST clones into cheap reference-count bumps or moves+=,-=, … evaluate in the operands' common type, then truncate back to the LHS type — new behavior that only applies now thatlongexists (not a pre-existingint-only bug)static intconstantPlatform & CI
macOS Apple Silicon (arm64) support
as/gccinvocations are prefixed with-arch x86_64under#[cfg(target_arch = "aarch64")]so the external toolchain cross-targets x86-64 (ncc emits x86-64 machine code)LC_BUILD_VERSIONload command (macOS 11.0), silencingld's "no platform load command found" warningubuntu-latestandmacos-latest, installs Rosetta on macOS, usestaiki-e/install-actionforcargo-llvm-cov, and tags Codecov uploads with per-OS flagsTest runner
rayon(global pool bounds total concurrency; ~7× faster locally)--external-linkerand per-test--no-icedruns gated to Linux, with one non-Linux--no-icedsmoke test to keep the arm64asshim covered (coverage is unioned across the matrix)test = false) socargo testreports a single summaryDocumentation
wild-linker/wild) and noted macOS support is no longer Intel-onlylongand casts; warning catalog expanded with the five new diagnosticsGrammar
Tests
tests/c_programs/warnings/suite: each new warning has a paired positive (shift_count.c) and negative (no_shift_count.c) fixture to assert it both fires and stays silentinvalid_parse/invalid_semanticsfixtures:case_static_decl,label_long_decl,case_div_by_zero,int_wrapping/{above_max,below_min}large_shift_immediate.candcompound_assign_mixed_types.ccoverageTest Plan
cargo buildandcargo build --testssucceed (Linux)cargo testpasses (full Sandler + custom suites, parallel runner)make qualityclean (fmt, sort, clippy-D warnings, machete)LC_BUILD_VERSIONverified locally (platform=MACOS, minos/sdk=11.0) via forced Mach-O emissionmacos-latest(Apple Silicon) — the new path this PR enablesubuntu-latest🤖 Generated with Claude Code