Skip to content

Add test for ancestor/descendant type-equality constraints#10447

Merged
jkiviluoto-nv merged 5 commits intoshader-slang:masterfrom
cmarcelo:ancestor-descendant-type-equality-check
Mar 13, 2026
Merged

Add test for ancestor/descendant type-equality constraints#10447
jkiviluoto-nv merged 5 commits intoshader-slang:masterfrom
cmarcelo:ancestor-descendant-type-equality-check

Conversation

@cmarcelo
Copy link
Copy Markdown
Contributor

@cmarcelo cmarcelo commented Mar 9, 2026

Add a generics test that exercises equality constraints between nested types and their enclosing type:

  • Box == Box.Nested
  • Box.Nested == Box

@cmarcelo cmarcelo requested a review from a team as a code owner March 9, 2026 00:43
@cmarcelo cmarcelo requested review from bmillsNV and Copilot and removed request for a team March 9, 2026 00:43
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0f3652fd-cd99-486d-8d27-1cf197282e2a

📥 Commits

Reviewing files that changed from the base of the PR and between fdab38b and 7ec29c0.

📒 Files selected for processing (1)
  • tests/language-feature/generics/type-equality-ancestor-ordering.slang

📝 Walkthrough

Walkthrough

Adds a new test that exercises generic type-equality constraints involving an ancestor (nested) relationship, defining struct Box<T> with Nested<U> and two generic functions that assert opposite directions of equality, then invoking both with int and expecting constraint diagnostics.

Changes

Cohort / File(s) Summary
New Test
tests/language-feature/generics/type-equality-ancestor-ordering.slang
Adds test file defining struct Box<T> and nested struct Box<T>::Nested<U>, two generic functions triggerA<X>() where Box<X> == Box<X>.Nested<X> and triggerB<X>() where Box<X>.Nested<X> == Box<X>, plus useIt() invoking both with int and CHECKs for diagnostics.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hop through boxes, one and two,
Nested loops of type and view,
Equality dreams that twist and bend,
I test them till the errors end,
A rabbit cheers: the checks are through!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a test for ancestor/descendant type-equality constraints, which is clearly reflected in the file addition and test content.
Description check ✅ Passed The description is directly related to the changeset, detailing the specific equality constraints being tested (Box == Box.Nested and the opposite direction), which matches the test file content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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-DAG lines are identical, so the test can pass without proving that triggerA<int>() and triggerB<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

📥 Commits

Reviewing files that changed from the base of the PR and between d138e76 and fdab38b.

📒 Files selected for processing (1)
  • tests/language-feature/generics/type-equality-ancestor-ordering.slang

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 covering Box<X> == Box<X>.Nested<X> and the reversed constraint.
  • Verifies both instantiations emit the expected diagnostic.

@aidanfnv aidanfnv added the pr: non-breaking PRs without breaking changes label Mar 10, 2026
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>
@cmarcelo cmarcelo force-pushed the ancestor-descendant-type-equality-check branch from fdab38b to 7ec29c0 Compare March 11, 2026 15:42
@github-actions

This comment has been minimized.

@cmarcelo cmarcelo requested a review from aidanfnv March 11, 2026 19:21
Copy link
Copy Markdown
Contributor

@aidanfnv aidanfnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@aidanfnv aidanfnv added this pull request to the merge queue Mar 12, 2026
@aidanfnv aidanfnv removed this pull request from the merge queue due to a manual request Mar 12, 2026
@aidanfnv aidanfnv added this pull request to the merge queue Mar 12, 2026
github-merge-queue bot pushed a commit that referenced this pull request Mar 12, 2026
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>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@aidanfnv aidanfnv added this pull request to the merge queue Mar 12, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@aidanfnv aidanfnv added this pull request to the merge queue Mar 12, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@aidanfnv aidanfnv enabled auto-merge March 12, 2026 15:57
@github-actions

This comment has been minimized.

@aidanfnv aidanfnv removed the request for review from bmillsNV March 12, 2026 18:24
@github-actions

This comment has been minimized.

@aidanfnv aidanfnv disabled auto-merge March 12, 2026 20:46
@aidanfnv aidanfnv enabled auto-merge March 12, 2026 20:46
@github-actions
Copy link
Copy Markdown
Contributor

Review: Add test for ancestor/descendant type-equality constraints

Clean, minimal test-only PR. LGTM ✅

Summary

Adds a single DIAGNOSTIC_TEST:SIMPLE that verifies the compiler correctly rejects unsatisfiable type-equality where constraints between an enclosing generic type (Box<X>) and its nested type (Box<X>.Nested<X>), and that it does so symmetrically regardless of operand order.

Verified

  • Diagnostic format: DIAGNOSTIC_TEST:SIMPLE(diag=CHECK): with positional /*CHECK: ... */ blocks — consistent with existing tests (e.g., where-optional-1.slang) and docs/diagnostics.md.
  • Error code: E38029 (type-argument-does-not-conform-to-interface) confirmed against slang-diagnostics.lua:3639. Each CHECK block correctly annotates both the error code line and the span message line produced by the diagnostic.
  • Caret alignment: 4 spaces + 8 carets (^^^^^^^^) correctly spans the 8-character identifiers triggerA/triggerB at columns 5–12 of the call sites.
  • Both orderings tested: triggerA constrains Box<X> == Box<X>.Nested<X>, triggerB constrains the reverse — proving symmetric rejection.
  • Positional disambiguation: Each /*CHECK: ... */ block is anchored to its preceding source line, so both calls are independently verified despite producing textually identical diagnostics.
  • Exhaustive mode (default): The test cannot pass vacuously — crashes, silent acceptance, or unexpected/missing diagnostics all cause failure.
  • No GPU dependency: Diagnostic tests run without hardware, so all CI platforms can validate this.

@jkiviluoto-nv jkiviluoto-nv disabled auto-merge March 13, 2026 08:35
@jkiviluoto-nv jkiviluoto-nv merged commit 475396e into shader-slang:master Mar 13, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants