Repository navigation
Description
Summary
Add missing operator-dispatch regression tests for already-working binary operators. The requirements campaign probed *, /, !=, <, <=, >, and >=, but those cases are not covered by durable tests.
Spec
§11.7 maps fixed operator method names: mul, div, ne, lt, le, gt, and ge, and requires static resolution with exactly one applicable implementation.
Current state
Sema maps binary operators to method names at src/SemaCheck.w:3703-3715, selects left/right candidates at src/SemaCheck.w:3767-3800, and routes comparison/arithmetic operators through that mechanism at src/SemaCheck.w:4109-4170. Existing tests cover add/sub/right-side dispatch (test/spec/spec_ss11_7_operator_one_impl_rule.w:6-34) and matmul (test/spec/spec_ss11_7_multi_index_and_dispatch.w:108-115), but not all probed operators. Negative tests already cover ambiguity and inapplicable implementations (test/compile_errors/err_operator_ambiguous_two_impls.w, test/compile_errors/err_operator_inapplicable_impl.w).
Implementation plan
- Add a single spec test file with a small user type implementing
mul,div,ne,lt,le,gt, andge. - Exercise both value and borrowed receiver styles where currently supported, but avoid relying on Prelude operator traits Add/Sub/Mul/Div/MatMul/Neg (§11.7) #469's optional trait declarations.
- Include one chained expression where safe, and keep comparison results
bool. - Add a negative test for a comparison operator method returning non-bool if existing
err_operator_compare_non_bool.wis not sufficient. - Do not change operator resolution unless the new tests expose a real bug.
Test plan
Add test/spec/spec_ss11_7_operator_dispatch_more.w:
a * bcallsmula / bcallsdiva != bcallsne<,<=,>,>=call the matching methods
Verify/extend:
test/compile_errors/err_operator_compare_non_bool.wtest/compile_errors/err_operator_ambiguous_two_impls.w
Acceptance criteria
- All requirement IDs listed in the original issue have positive operator-dispatch coverage.
- Comparison method return type remains enforced as bool.
- No behavior changes are made unless tests reveal a defect.
with build && with build :fixpoint && with build :testpass.
Dependencies
#464 adds unary neg dispatch tests. #469 adds optional prelude trait declarations.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 11.7.1.27, 11.7.1.28, 11.7.1.32, 11.7.1.33, 11.7.1.34, 11.7.1.35, 11.7.1.36.
Activity
ehartford commentedon Jul 3, 2026
Closing — operator dispatch for mul/div and the full comparison family (ne/lt/le/gt/ge) pinned by spec_ss11_operator_dispatch_full (ec03406). §11.
test: coverage-sweep batch 2 (#483 #484 #522 #493 #494 #514 #515 #532)