skia2/resources/sksl/errors/InvalidAssignment.sksl
John Stiles a456175a07 Add expected errors to every test file.
This was (crudely) automated with shell scripts:
http://go/paste/5484300603490304

Change-Id: Ic9e1c93112772d303d1158eb26d995f27b439eba
Bug: skia:12665
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505637
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-02-08 18:20:25 +00:00

40 lines
1.6 KiB
Plaintext

struct S {
float f;
};
uniform int u;
void assign_to_literal() { 1 = 2; }
void assign_to_uniform() { u = 0; }
void assign_to_const() { const int x = 1; x = 0; }
void assign_to_const_swizzle() { const half4 x = half4(1); x.w = 0; }
void assign_to_repeated_swizzle() { half4 x; x.yy = half2(0); }
void assign_to_foldable_ternary_const_left() { const float l = 1; float r; (true ? l : r) = 0; }
void assign_to_foldable_ternary_const_right() { float l; const float r = 1; (false ? l : r) = 0; }
void assign_to_foldable_ternary_const_both() { const float l = 1; const float r = 1; (true ? l : r) = 0; }
void assign_to_unfoldable_ternary() { float l, r; (u > 0 ? l : r) = 0; }
void assign_to_unary_minus() { float x; -x = 0; }
void assign_to_unary_plus() { float x; +x = 0; } // TODO(skbug.com/10766)
void assign_to_const_param(const int x) { x = 0; }
void assign_to_const_array_param(const int x[1]) { x[0] = 0; }
void assign_to_const_struct_param(const S s) { s.f = 0; }
/*%%*
cannot assign to this expression
cannot modify immutable variable 'u'
cannot modify immutable variable 'x'
cannot assign to this expression
cannot write to the same swizzle field more than once
cannot modify immutable variable 'l'
cannot modify immutable variable 'r'
cannot modify immutable variable 'l'
cannot assign to this expression
cannot assign to this expression
cannot modify immutable variable 'x'
cannot modify immutable variable 'x'
cannot modify immutable variable 's'
*%%*/