Skip to content

Fix issue of missing scope for 'Differential' type#7433

Merged
kaizhangNV merged 2 commits intoshader-slang:masterfrom
kaizhangNV:auto_diff
Jun 12, 2025
Merged

Fix issue of missing scope for 'Differential' type#7433
kaizhangNV merged 2 commits intoshader-slang:masterfrom
kaizhangNV:auto_diff

Conversation

@kaizhangNV
Copy link
Copy Markdown
Contributor

Close #6756.

When we synthesize the struct decl for Differential type, we should add the ownedScope for this decl, because the scope is used in lots of locations in the following synthesized processes, e.g. constructor synthesize. And that could cause surprising behavior, e.g. the 'this' expression could access the members of parent struct decl.

Fix the issue by adding the scope. The containerDecl will be the Differential struct decl itself, parent scope will be the parent struct.

When we synthesize the struct decl for Differential type, we should
add the ownedScope for this decl, because the scope is used in lots
of locations in the following synthesized processes, e.g. constructor
synthesize. And that could cause surprising behavior, e.g. the 'this'
expression could access the members of parent struct decl.

Fix the issue by adding the scope. The containerDecl will be the
Differential struct decl itself, parent scope will be the parent struct.
@kaizhangNV kaizhangNV requested a review from a team as a code owner June 12, 2025 16:56
@kaizhangNV kaizhangNV added the pr: non-breaking PRs without breaking changes label Jun 12, 2025
@kaizhangNV kaizhangNV enabled auto-merge (squash) June 12, 2025 19:59
@kaizhangNV kaizhangNV disabled auto-merge June 12, 2025 19:59
@kaizhangNV kaizhangNV merged commit 60b66c3 into shader-slang:master Jun 12, 2025
17 checks passed
@kaizhangNV kaizhangNV deleted the auto_diff branch June 12, 2025 19:59
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.

Function with .Differential in signature for partially differentiable struct compiles to invalid WGSL with bad field access

2 participants