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

Add a new section that explains the variable scope problem with for-loop #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jkwak-work
Copy link
Contributor

I found a need to explain the behavior for the variable declared inside of for-loop.
The issue was asked on "Discussion":
shader-slang/slang#5824

@jkwak-work jkwak-work self-assigned this Dec 12, 2024
@jkwak-work jkwak-work force-pushed the variable_declaration_conflict_in_for_loop_when_input_is_hlsl branch from 90589ae to cc8f9d8 Compare December 12, 2024 00:45
@@ -75,6 +75,36 @@ int MyFunc()
}
```

#### Variable scope in `for`-loop follows the old FXC rule
The older version of HLSL compiler, FXC, had a little different variable scope for the `for`-loop compared to other languages.
Copy link
Contributor

Choose a reason for hiding this comment

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

By default, the language is slang so you will never run into this issue. This is only the case if the user explicitly specified -lang hlsl. We should simply advise users to not set input language to HLSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants