You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.
Summary
crates/graphcal-eval/src/eval_expr/arithmetic.rs deliberately introduces a narrowed OrderingOp type to remove an "impossible operator" fallback — then routes quantity comparisons back through a function that re-widens to BinOp and needs exactly that fallback.
The stated design
arithmetic.rs:183-194:
Restriction of BinOp to the four ordering comparison operators.
Carrying this typed subset lets apply_ordering dispatch without an "impossible" arm — the type system forbids non-ordering ops at the call site rather than checking at runtime.
The path that undoes it
Both eval_equality_values (arithmetic.rs:141) and eval_ordering_values (arithmetic.rs:178) funnel the quantity case through eval_comparison(op: BinOp, ...):
arithmetic.rs:220-238. The _ => arm is the runtime check OrderingOp exists to eliminate.
Impact
No wrong results — purely a type-safety and consistency gap. But it leaves an unreachable error path that must be kept alive and tested (see #1395, which tracks untested defensive internal-error guards in the same area).
Suggested fix
Widen the narrowed type to ComparisonOp { Eq, Ne, Lt, Gt, Le, Ge } and have both callers narrow once at entry. The fallback arm then disappears, matching the design the file already documents.
Provenance
Found during a full-workspace code review at 6e462341a (v0.0.1-alpha.27). Baseline at that commit: cargo clippy --workspace --all-targets clean, cargo test --workspace 2926 passed / 0 failed, cargo deny check advisories ok.
Warning
This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.
Summary
crates/graphcal-eval/src/eval_expr/arithmetic.rsdeliberately introduces a narrowedOrderingOptype to remove an "impossible operator" fallback — then routes quantity comparisons back through a function that re-widens toBinOpand needs exactly that fallback.The stated design
arithmetic.rs:183-194:The path that undoes it
Both
eval_equality_values(arithmetic.rs:141) andeval_ordering_values(arithmetic.rs:178) funnel the quantity case througheval_comparison(op: BinOp, ...):arithmetic.rs:220-238. The_ =>arm is the runtime checkOrderingOpexists to eliminate.Impact
No wrong results — purely a type-safety and consistency gap. But it leaves an unreachable error path that must be kept alive and tested (see #1395, which tracks untested defensive internal-error guards in the same area).
Suggested fix
Widen the narrowed type to
ComparisonOp { Eq, Ne, Lt, Gt, Le, Ge }and have both callers narrow once at entry. The fallback arm then disappears, matching the design the file already documents.Provenance
Found during a full-workspace code review at
6e462341a(v0.0.1-alpha.27). Baseline at that commit:cargo clippy --workspace --all-targetsclean,cargo test --workspace2926 passed / 0 failed,cargo deny check advisoriesok.