Skip to content

Add regression test for private cross-module constructor (#7152)#11622

Merged
expipiplus1 merged 1 commit into
shader-slang:masterfrom
expipiplus1:pr/regression-test-private-cross-module-ctor
Jun 23, 2026
Merged

Add regression test for private cross-module constructor (#7152)#11622
expipiplus1 merged 1 commit into
shader-slang:masterfrom
expipiplus1:pr/regression-test-private-cross-module-ctor

Conversation

@expipiplus1

@expipiplus1 expipiplus1 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings June 16, 2026 08:21
@expipiplus1 expipiplus1 requested a review from a team as a code owner June 16, 2026 08:21
@expipiplus1 expipiplus1 requested review from bmillsNV and removed request for a team June 16, 2026 08:21
@expipiplus1 expipiplus1 added the pr: non-breaking PRs without breaking changes label Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c2bfa7b6-e336-4fa5-81ed-b4658d1b3800

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3d21c and c69f1ee.

📒 Files selected for processing (2)
  • tests/diagnostics/private-init-cross-module-helper.slang
  • tests/diagnostics/private-init-cross-module.slang

📝 Walkthrough

Walkthrough

Two new Slang diagnostic test files are added as a regression test for issue #7152. A helper module defines public struct B with a default/internal __init(float b) constructor and public struct C with an explicitly private __init(float b) constructor. The main test imports the helper, attempts to call both constructors from a vertex shader, and uses //CHECK: directives to assert accessibility errors are emitted rather than a compiler crash.

Changes

Cross-module private constructor diagnostic regression test

Layer / File(s) Summary
Test fixture structs with constructor visibility variants
tests/diagnostics/private-init-cross-module-helper.slang
Defines public struct B with a default/internal __init(float b) and public struct C with an explicitly private __init(float b) to exercise both implicit and explicit constructor visibility resolution paths.
Cross-module constructor call and diagnostic assertions
tests/diagnostics/private-init-cross-module.slang
Imports the helper module, defines a vertex shader that attempts to instantiate both structs via their single-parameter constructors, and asserts accessibility-related error diagnostics via //CHECK: markers.

Suggested reviewers

  • bmillsNV
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add regression test for private cross-module constructor (#7152)' accurately and concisely describes the main change: adding a regression test for issue #7152.
Description check ✅ Passed The description clearly explains the fix for issue #7152 (segfault to accessibility error) and describes the regression test structure with separate modules.
Linked Issues check ✅ Passed The PR directly addresses issue #7152 by adding a regression test that verifies the compiler now reports accessibility diagnostics instead of segfaulting when calling private constructors cross-module.
Out of Scope Changes check ✅ Passed All changes are focused on adding regression tests for issue #7152; no unrelated modifications or out-of-scope changes are present.
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.


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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 B with 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.

Comment thread tests/diagnostics/private-init-cross-module.slang Outdated
@expipiplus1 expipiplus1 force-pushed the pr/regression-test-private-cross-module-ctor branch from 2fb9d56 to 5e3d21c Compare June 22, 2026 12:59
github-actions[bot]

This comment was marked as outdated.

@expipiplus1 expipiplus1 force-pushed the pr/regression-test-private-cross-module-ctor branch from 5e3d21c to c69f1ee Compare June 22, 2026 13:58

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:SIMPLE test pair. The helper module declares public struct B with a default-visibility __init(float) and public struct C with an explicit private __init(float). The main test imports the helper and calls B(0.0) / C(0.0) from a vertex entry point, expecting declaration not accessible and 'X.init' is not accessible diagnostics 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 "..." with TEST_IGNORE_FILE on the helper) matches tests/diagnostics/autodiff-custom-diff-non-exported-import{,-helper}.slang.

@jhelferty-nv jhelferty-nv removed the request for review from bmillsNV June 22, 2026 22:13
@expipiplus1 expipiplus1 merged commit a39e49c into shader-slang:master Jun 23, 2026
47 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.

segmentation fault when calling private constructor with only one argument of struct defined in separate file

2 participants