feat: generics multiple-bound conjunctions (ILO-386)#633
Merged
danieljohnmorris merged 1 commit intoMay 22, 2026
Merged
Conversation
Extend bounded generics (ILO-61) to support conjunctions of bounds via `+` syntax: `<a:numeric+comparable>` means `a` must satisfy ALL listed bounds (intersection, not union). Changes: - ast: `type_params` changed from `Vec<(String, Bound)>` to `Vec<(String, Vec<Bound>)>` — each type variable carries a conjunction of bounds; an empty list or `[Any]` means unconstrained. - parser: after consuming the first bound name, loop consuming `+` and another bound ident to build the conjunction vec. - verify: `type_bounds` map now holds `Vec<Bound>`; call-site checker iterates all bounds in the conjunction and emits ILO-T044 for each unsatisfied one. - tests: 10 regression tests covering acceptance (n for numeric+comparable), rejection (t fails numeric, b fails numeric+text), 3-bound impossible conjunctions, and order independence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
+syntax:<a:numeric+comparable>meansamust satisfy ALL listed bounds (intersection, not union).Changes
src/ast/mod.rs:type_paramsfield changed fromVec<(String, Bound)>toVec<(String, Vec<Bound>)>— each type variable carries a conjunction of bounds.src/parser/mod.rs: After consuming the first bound name, loops consuming++ another bound ident to build the conjunction. No tokenizer changes needed —Token::Plusalready existed.src/verify.rs:type_boundsmap now holdsVec<Bound>; call-site bound checker iterates all bounds in the conjunction and emitsILO-T044for each unsatisfied one.tests/regression_generics_multibound.rs: 10 regression tests covering:nsatisfiesnumeric+comparabletfailsnumericinnumeric+comparablebfails both bounds innumeric+textnumeric+comparable+text)comparable+numericbehaves same asnumeric+comparable)Test plan
cargo test --test regression_generics_multibound— 10/10 passcargo test --lib— 3342/3342 passCloses ILO-386
🤖 Generated with Claude Code