Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in default ctor synthesizing #6527

Merged
merged 5 commits into from
Mar 7, 2025

Conversation

kaizhangNV
Copy link
Contributor

This is fix for the implementation bug, when a struct has explict ctor we should not synthesize the default ctor anymore.

@kaizhangNV kaizhangNV requested a review from a team as a code owner March 5, 2025 19:07
@kaizhangNV kaizhangNV added the pr: non-breaking PRs without breaking changes label Mar 5, 2025
This is fix for the implementation bug, when a struct has explict ctor
we should not synthesize the default ctor anymore.
A struct could has no synthesized ctor when it inherits from a base
struct that has explicit ctor, in this case, we should check whether
this is a c-style struct and report error when it's assigned by initializer
list.
@kaizhangNV kaizhangNV merged commit e1952dc into shader-slang:master Mar 7, 2025
16 of 17 checks passed
@kaizhangNV kaizhangNV deleted the default-ctor-fix branch March 7, 2025 04:38
// more proper solution for array initialization, so if the right hand side is an array
// type, we will not report error and fall-back to legacy initializer list logic.
bool isArrayType = as<ArrayExpressionType>(toType) != nullptr;
if (!isCStyle && !isArrayType)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the ordering of steps that needs to happen is:
Try match to a ctor call, if succeeded done.
If array type and empty init list, try construct a single value of the element type with empty init list, if succeed, create a MakeArrayFromSingleValue(singleValue) node for the array value, done.
If that failed, fallback to cstyle logic if applicable.
If that failed, error.

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.

2 participants