diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-07-07 03:52:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-06 15:52:00 -0400 |
| commit | cdfea42f1b28c6ec7b13500a64be823f67bf8e0a (patch) | |
| tree | 4444c21ac369ce8f4c99370fcd47153eeb35581f /tests/bugs | |
| parent | 4a88139a86596fd1a546af84ab3210ea3013c58d (diff) | |
Fix erroneous error claiming variable is being used before its declaration (#2958)
* Simplify type of diagnoseImpl
* Show source line for Note diagnostics, opting out of this where appropriate
* Make declared after use diagnostic clearer
* Fix erroneous error claiming variable is being used before its declaration
Closes https://github.com/shader-slang/slang/issues/2936
* Fix build on msvc
---------
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/generic-type-arg-overloaded.slang.expected | 6 | ||||
| -rw-r--r-- | tests/bugs/gh-2936.slang | 53 |
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/bugs/generic-type-arg-overloaded.slang.expected b/tests/bugs/generic-type-arg-overloaded.slang.expected index 390c4fe00..1c41da717 100644 --- a/tests/bugs/generic-type-arg-overloaded.slang.expected +++ b/tests/bugs/generic-type-arg-overloaded.slang.expected @@ -4,11 +4,17 @@ tests/bugs/generic-type-arg-overloaded.slang(14): error 30200: declaration of 'S struct Stuff {} ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(11): note: see previous declaration of 'Stuff' +struct Stuff : IThing { int getVal() { return 1; } } + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(26): error 39999: ambiguous reference to 'Stuff' return util<Stuff>() ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(14): note 39999: candidate: struct Stuff +struct Stuff {} + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(11): note 39999: candidate: struct Stuff +struct Stuff : IThing { int getVal() { return 1; } } + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(32): error 39999: expected a generic when using '<...>' (found: '() -> int') + nonGeneric<G>(); ^~~~~~~~~~ diff --git a/tests/bugs/gh-2936.slang b/tests/bugs/gh-2936.slang new file mode 100644 index 000000000..20bfa1924 --- /dev/null +++ b/tests/bugs/gh-2936.slang @@ -0,0 +1,53 @@ +//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj -output-using-type + +// CHECK: 4 +// CHECK-NEXT: 99 +// CHECK-NEXT: 111 +// CHECK-NEXT: 40 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + outputBuffer[0] = f(); + outputBuffer[1] = g(); + outputBuffer[2] = h(); + outputBuffer[3] = k(30, 40); +} + +static let x = 1; + +func f() -> int +{ + let y = x; // should refer to the global x + let x = 3; + return x + y; // should refer to the local x +} +func g() -> int +{ + // Can we shadow this keyword + int out; + out = 99; + return out; +} + +static var input = 999; +func h() -> int +{ + // This should still parse as an identifier (it's a keyword, being shadowed + // by something in a parent scope) + input = 10; + int input = input; + input += 101; + return input; +} + +int k(int a, int b) +{ + int umax = max(a, b); + + int max = umax; + return max; +} |
