Revision a050f4a144d5ab36c93cd0a443767340301fb32e authored by Tim Foley on 26 January 2018, 21:23:16 UTC, committed by GitHub on 26 January 2018, 21:23:16 UTC
The basic problem here arises when a local variable is used either before its own declaration:

```hlsl
int a = b;
...
int b = 0;
```

or when a local variable is used *in* its own decalration:

```hlsl
int b = b;
```

In each case, Slang considers the scope of the `{}`-enclosed function body (or nested statement) as a whole, and so the lookup can "see" the declaration even if it is later in the same function.
This behavior isn't really correct for HLSL semantics, so the right long-term fix is to change our scoping rules, but for now users really just want the compiler to not crash on code like this, and give an error message that points at the issue.

This change makes both of the above examples print an error message saying that variable `b` was used before its declaration, which is accurate to the way that Slang is interpreting those code examples.
This is currently treated as a fatal error, so that compilation aborts right away, to avoid all of the downstream crashes that these cases were causing.
1 parent 4cd18ec
History
File Mode Size
build
docs
examples
external
source
tests
tools
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 398 bytes
.gitmodules -rw-r--r-- 107 bytes
.travis.yml -rw-r--r-- 1.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
Makefile -rw-r--r-- 6.3 KB
README.md -rw-r--r-- 6.1 KB
appveyor.yml -rw-r--r-- 3.5 KB
slang.h -rw-r--r-- 41.9 KB
slang.sln -rw-r--r-- 9.1 KB
test.bat -rw-r--r-- 1.4 KB

README.md

back to top