[webkit-changes] [WebKit/WebKit] e90fdf: [WGSL] Variables initializer shouldn't be a reference
Tadeu Zagallo
noreply at github.com
Mon Jun 5 01:54:12 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e90fdfdcdf8ca3d871a80896ba5e635b83c172e4
https://github.com/WebKit/WebKit/commit/e90fdfdcdf8ca3d871a80896ba5e635b83c172e4
Author: Tadeu Zagallo <tzagallo at apple.com>
Date: 2023-06-05 (Mon, 05 Jun 2023)
Changed paths:
M Source/WebGPU/WGSL/TypeCheck.cpp
A Source/WebGPU/WGSL/tests/valid/var-initialization-with-var.wgsl
Log Message:
-----------
[WGSL] Variables initializer shouldn't be a reference
https://bugs.webkit.org/show_bug.cgi?id=257601
rdar://110105334
Reviewed by Mike Wyrzykowski.
When initializing a variable, the value used to initialize it should be unpacked
if it's a reference. E.g.:
var a = 0;
var b = a;
b = 1;
The above program should not change the value of `a`, and references to `b` should
have type `ref<i32>`, not `ref<ref<i32>>`. In order to fix that, when we infer the
type of a variable initializer (which doesn't have an explicit type annotation), if
the is a reference (as it would be for `a` in the example above, which would have type
`ref<i32>`), we should use the referenced type instead (i.e. `i32` in this example)
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visitVariable):
Canonical link: https://commits.webkit.org/264860@main
More information about the webkit-changes
mailing list