Add regression test for private cross-module constructor (#7152)#11622
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo new Slang diagnostic test files are added as a regression test for issue ChangesCross-module private constructor diagnostic regression test
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
Pull request overview
Adds a multi-file diagnostics regression test to ensure the compiler reports an accessibility error (instead of crashing) when a private single-parameter struct constructor is called across a module boundary (issue #7152).
Changes:
- Add a helper module defining
public struct Bwith a private one-arg__init. - Add a diagnostic test that imports the helper module, attempts to call the private constructor, and checks the resulting accessibility diagnostic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/diagnostics/private-init-cross-module.slang | New diagnostic regression test that imports a helper module and asserts the accessibility error on a private cross-module constructor call. |
| tests/diagnostics/private-init-cross-module-helper.slang | New helper module declaring struct B with a private single-parameter constructor used by the regression test. |
2fb9d56 to
5e3d21c
Compare
5e3d21c to
c69f1ee
Compare
There was a problem hiding this comment.
Verdict: ✅ Clean — no significant issues found
Tests-only PR adding a regression test pair for issue #7152 (cross-module call to a single-parameter private constructor previously segfaulted; now produces an accessibility diagnostic). Two reviewers (code-quality, test-coverage) ran; no Bug/Gap/Question findings cleared the editorial filter (severity + confidence ≥ 85 + verifiable evidence quote).
Changes Overview
Cross-module private-constructor regression test (tests/diagnostics/private-init-cross-module-helper.slang, tests/diagnostics/private-init-cross-module.slang)
- What changed: New
DIAGNOSTIC_TEST:SIMPLEtest pair. The helper module declarespublic struct Bwith a default-visibility__init(float)andpublic struct Cwith an explicitprivate __init(float). The main test imports the helper and callsB(0.0)/C(0.0)from a vertex entry point, expectingdeclaration not accessibleand'X.init' is not accessiblediagnostics plus the cascading type-mismatch errors. Mirrors the reproducer in #7152 to lock in the cross-module accessibility-diagnostic path that replaced the segfault. File-pair convention (module "..."+import "..."withTEST_IGNORE_FILEon the helper) matchestests/diagnostics/autodiff-custom-diff-non-exported-import{,-helper}.slang.
Calling a private single-parameter constructor of a struct defined in a separate module used to segfault; it now reports an accessibility error. Adds a regression test, with the struct in an imported module to exercise the cross-module path that originally crashed.
Fixes #7152.