mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Snapshot test local variable inference
This commit is contained in:
committed by
Dzmitry Malyshau
parent
beabd62d96
commit
c69736210a
@@ -21,8 +21,8 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4<f32> {
|
||||
|
||||
let a = bar.data[arrayLength(&bar.data) - 2u];
|
||||
|
||||
var c: array<i32, 5> = array<i32, 5>(a, i32(b), 3, 4, 5);
|
||||
c[vi + 1u] = 42;
|
||||
var c = array<i32, 5>(a, i32(b), 3, 4, 5);
|
||||
c[vi + 1u] = 42;
|
||||
let value = c[vi];
|
||||
|
||||
return vec4<f32>(vec4<i32>(value));
|
||||
|
||||
@@ -33,12 +33,12 @@ fn main([[builtin(global_invocation_id)]] global_invocation_id : vec3<u32>) {
|
||||
return;
|
||||
}
|
||||
|
||||
var vPos : vec2<f32> = particlesSrc.particles[index].pos;
|
||||
var vVel : vec2<f32> = particlesSrc.particles[index].vel;
|
||||
var vPos = particlesSrc.particles[index].pos;
|
||||
var vVel = particlesSrc.particles[index].vel;
|
||||
|
||||
var cMass : vec2<f32> = vec2<f32>(0.0, 0.0);
|
||||
var cVel : vec2<f32> = vec2<f32>(0.0, 0.0);
|
||||
var colVel : vec2<f32> = vec2<f32>(0.0, 0.0);
|
||||
var cMass = vec2<f32>(0.0, 0.0);
|
||||
var cVel = vec2<f32>(0.0, 0.0);
|
||||
var colVel = vec2<f32>(0.0, 0.0);
|
||||
var cMassCount : i32 = 0;
|
||||
var cVelCount : i32 = 0;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ var<storage> v_indices: [[access(read_write)]] PrimeIndices;
|
||||
// Though the conjecture has not been proven, no counterexample has ever been found.
|
||||
// This function returns how many times this recurrence needs to be applied to reach 1.
|
||||
fn collatz_iterations(n_base: u32) -> u32 {
|
||||
var n: u32 = n_base;
|
||||
var n = n_base;
|
||||
var i: u32 = 0u;
|
||||
loop {
|
||||
if (n <= 1u) {
|
||||
|
||||
@@ -43,7 +43,7 @@ fn fs_main(
|
||||
) -> [[location(0)]] vec4<f32> {
|
||||
let normal: vec3<f32> = normalize(raw_normal);
|
||||
// accumulate color
|
||||
var color: vec3<f32> = c_ambient;
|
||||
var color = c_ambient;
|
||||
var i: u32 = 0u;
|
||||
loop {
|
||||
if (i >= min(u_globals.num_lights.x, c_max_lights)) {
|
||||
|
||||
@@ -14,8 +14,8 @@ var r_data: Data;
|
||||
[[stage(vertex)]]
|
||||
fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput {
|
||||
// hacky way to draw a large triangle
|
||||
var tmp1: i32 = i32(vertex_index) / 2;
|
||||
var tmp2: i32 = i32(vertex_index) & 1;
|
||||
var tmp1 = i32(vertex_index) / 2;
|
||||
var tmp2 = i32(vertex_index) & 1;
|
||||
let pos = vec4<f32>(
|
||||
f32(tmp1) * 4.0 - 1.0,
|
||||
f32(tmp2) * 4.0 - 1.0,
|
||||
|
||||
@@ -475,6 +475,42 @@ fn let_type_mismatch() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_var_type_mismatch() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
var x: f32 = 1;
|
||||
}
|
||||
"#,
|
||||
r#"error: the type of `x` is expected to be [1]
|
||||
┌─ wgsl:3:21
|
||||
│
|
||||
3 │ var x: f32 = 1;
|
||||
│ ^ definition of `x`
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_var_missing_type() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
var x;
|
||||
}
|
||||
"#,
|
||||
r#"error: variable `x` needs a type
|
||||
┌─ wgsl:3:21
|
||||
│
|
||||
3 │ var x;
|
||||
│ ^ definition of `x`
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
macro_rules! check_validation_error {
|
||||
// We want to support an optional guard expression after the pattern, so
|
||||
// that we can check values we can't match against, like strings.
|
||||
|
||||
Reference in New Issue
Block a user