feat(native): add checked scalar conversions - #8285
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (20)
📝 WalkthroughWalkthroughAdded seven checked ChangesNative scalar conversions
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Source as Source call
participant HIR as HIR call lowering
participant Dispatch as Native dispatch table
participant Runtime as native_value_profile
Source->>HIR: Call i32, u64, f32, or another native conversion
HIR->>HIR: Validate callee, arity, spreads, and type arguments
HIR->>Dispatch: Lower validated native method call
Dispatch->>Runtime: Invoke exported scalar conversion
Runtime-->>Source: Return converted number or throw conversion error
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # docs/api/perry.d.ts # docs/src/api/reference.md
|
Merging. Runtime 2571 passed / 0 failed / 4 ignored, codegen 28 suites, 1524 passed, 9 failed — all nine baseline, Rejecting values that cannot be represented without changing their meaning is the right contract for a checked-conversion slice — the failure mode a silent One thing I fixed during the merge, and it was not yours. That is the third gate I broke today by merging on a partial check ( |
Summary
Add the checked scalar-conversion slice proposed by the stable
perry/nativevalue profile. The new value-sidei32,i64,u32,u64,usize,f32, andf64functions reject values that cannot be represented without changing their meaning.Changes
TypeErrorandRangeErrorfailuresRelated issue
Refs #6827
Test plan
./scripts/test_affected_crates.sh --base origin/main./scripts/pre-tag-check.sh --quickcargo test -p perry-runtime native_value_profile --lib -- --nocapturecargo test -p perry-hir --test native_arena native_scalar -- --nocapturecargo test -p perry-codegen --test manifest_consistencyPERRY=target/perry-dev/perry bash tests/test_native_value_profile.shdocs/src/and generated API documentationScreenshots / output
The executable regression prints
PASSafter checking POD layout, bounds, precision, float rounding, and catchable conversion errors.Checklist
feat:/fix:/docs:/chore:prefix convention used in the logSummary by CodeRabbit
New Features
f32rounding to its representable value.Documentation
Tests