File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -907,7 +907,13 @@ impl Components {
907
907
* comp = Self :: letter_component ( ch) . ok_or ( Error :: BadAccessor ( name_span) ) ?;
908
908
}
909
909
910
- Ok ( Components :: Swizzle { size, pattern } )
910
+ if name. chars ( ) . all ( |c| matches ! ( c, 'x' | 'y' | 'z' | 'w' ) )
911
+ || name. chars ( ) . all ( |c| matches ! ( c, 'r' | 'g' | 'b' | 'a' ) )
912
+ {
913
+ Ok ( Components :: Swizzle { size, pattern } )
914
+ } else {
915
+ Err ( Error :: BadAccessor ( name_span) )
916
+ }
911
917
}
912
918
}
913
919
Original file line number Diff line number Diff line change @@ -2371,3 +2371,21 @@ fn local_const_from_global_var() {
2371
2371
"### ,
2372
2372
) ;
2373
2373
}
2374
+
2375
+ #[ test]
2376
+ fn only_one_swizzle_type ( ) {
2377
+ check (
2378
+ "
2379
+ const ok1 = vec2(0.0, 0.0).xy;
2380
+ const ok2 = vec2(0.0, 0.0).rg;
2381
+ const err = vec2(0.0, 0.0).xg;
2382
+ " ,
2383
+ r###"error: invalid field accessor `xg`
2384
+ ┌─ wgsl:4:36
2385
+ │
2386
+ 4 │ const err = vec2(0.0, 0.0).xg;
2387
+ │ ^^ invalid accessor
2388
+
2389
+ "### ,
2390
+ ) ;
2391
+ }
You can’t perform that action at this time.
0 commit comments