Add unit test for self-referential initializer expressions.

These don't compile in GLSL, so they shouldn't compile in SkSL either--
and fortunately, they do not.

(In C++, and consequently in Metal, these expressions are considered
legal by the grammar and do compile, but generate garbage output.)

Change-Id: I6c7bea70b3d91677ccd8fcbad1eba123d655e856
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329359
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-10-23 09:58:56 -04:00 committed by Skia Commit-Bot
parent 58cf3fe83b
commit 15d8174fc9
3 changed files with 7 additions and 0 deletions

View File

@ -107,6 +107,7 @@ sksl_error_tests = [
"$_tests/sksl/errors/ReturnFromVoid.sksl",
"$_tests/sksl/errors/ReturnMissingValue.sksl",
"$_tests/sksl/errors/ReturnTypeMismatch.sksl",
"$_tests/sksl/errors/SelfReferentialInitializerExpression.sksl",
"$_tests/sksl/errors/SpuriousFloat.sksl",
"$_tests/sksl/errors/StaticIfTest.sksl",
"$_tests/sksl/errors/StaticSwitchConditionalBreak.sksl",

View File

@ -0,0 +1,2 @@
float foo(float v) { return v; }
void main() { float x = foo(x); }

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 2: unknown identifier 'x'
1 error