xref: /aosp_15_r20/external/skia/resources/sksl/errors/InvalidAssignment.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1struct S  {
2    float f;
3};
4
5struct T {
6    S s;
7};
8
9uniform int u;
10
11void assign_to_literal()                      { 1 = 2; }
12void assign_to_uniform()                      { u = 0; }
13void assign_to_const()                        { const int x = 1; x = 0; }
14
15void assign_to_const_swizzle()                { const half4 x = half4(1); x.w = 0; }
16void assign_to_repeated_swizzle()             { half4 x; x.yy = half2(0); }
17
18void assign_to_foldable_ternary_const_left()  { const float l = 1; float r; (true ? l : r) = 0; }
19void assign_to_foldable_ternary_const_right() { float l; const float r = 1; (false ? l : r) = 0; }
20void assign_to_foldable_ternary_const_both()  { const float l = 1; const float r = 1; (true ? l : r) = 0; }
21void assign_to_unfoldable_ternary()           { float l, r; (u > 0 ? l : r) = 0; }
22void assign_to_unary_minus()                  { float x; -x = 0; }
23void assign_to_unary_plus()                   { float x; +x = 0; }  // TODO(skbug.com/10766)
24
25void assign_to_const_param(const int x)             { x = 0; }
26void assign_to_const_array_param(const int x[1])    { x[0] = 0; }
27void assign_to_const_struct_param(const S s)        { s.f = 0; }
28void assign_to_const_nested_struct_param(const T t) { t.s.f = 0; }
29
30/*%%*
31cannot assign to this expression
32cannot modify immutable variable 'u'
33cannot modify immutable variable 'x'
34cannot assign to this expression
35cannot write to the same swizzle field more than once
36cannot modify immutable variable 'l'
37cannot modify immutable variable 'r'
38cannot modify immutable variable 'l'
39cannot assign to this expression
40cannot assign to this expression
41cannot modify immutable variable 'x'
42cannot modify immutable variable 'x'
43cannot modify immutable variable 's.f'
44cannot modify immutable variable 't.s'
45*%%*/
46