Add test for ancestor/descendant type-equality constraints#10447
Add test for ancestor/descendant type-equality constraints#10447cmarcelo wants to merge 1 commit intoshader-slang:masterfrom
Conversation
Add a generics test that exercises equality constraints between nested types and their enclosing type: - Box<X> == Box<X>.Nested<X> - Box<X>.Nested<X> == Box<X>
📝 WalkthroughWalkthroughA new test file is added to verify generic type equality constraints involving ancestor ordering. The test defines a generic struct with nested types and functions that enforce bidirectional type equality constraints, checking that expected constraint violations are properly detected. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/language-feature/generics/type-equality-ancestor-ordering.slang (1)
23-24: Make the two expected failures distinguishable.These two
CHECK_FAIL-DAGlines are identical, so the test can pass without proving thattriggerA<int>()andtriggerB<int>()each failed independently. Please anchor each expectation to its specific instantiation site, or split the two directions into separate tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 14f298e9-d2e6-4e08-af80-1317b32a8eba
📒 Files selected for processing (1)
tests/language-feature/generics/type-equality-ancestor-ordering.slang
There was a problem hiding this comment.
Pull request overview
Adds a new Slang generics regression test to ensure type-equality constraints behave consistently when comparing an enclosing generic type with a nested generic type, regardless of operand order.
Changes:
- Introduces a
CHECK_FAIL-based test coveringBox<X> == Box<X>.Nested<X>and the reversed constraint. - Verifies both instantiations emit the expected diagnostic.
| triggerB<int>(); | ||
| } | ||
|
|
||
| //CHECK_FAIL-DAG: error 38029: type argument 'Box<int>.Nested<int>' does not conform to the required interface 'Box<int>' |
There was a problem hiding this comment.
Please update these checks to use the new diagnostics format. The format of these diagnostics has recently been changed, so these checks will now fail the CI tests until they are updated to the new format.
Please see https://github.com/shader-slang/slang/blob/master/docs/diagnostics.md for an explanation of the new format, and (more importantly for this case) https://github.com/shader-slang/slang/blob/master/docs/diagnostics.md#matching-fields for how to check the diagnostics in the new format.
Add a generics test that exercises equality constraints between nested types and their enclosing type: