diff --git a/src/front/glsl/functions.rs b/src/front/glsl/functions.rs index 36db43c0c2..870d605372 100644 --- a/src/front/glsl/functions.rs +++ b/src/front/glsl/functions.rs @@ -243,7 +243,7 @@ impl Parser { } } } - TypeInner::Struct { .. } => ctx.add_expression( + TypeInner::Struct { .. } | TypeInner::Array { .. } => ctx.add_expression( Expression::Compose { ty, components: args.into_iter().map(|arg| arg.0).collect(), @@ -253,7 +253,7 @@ impl Parser { ), _ => { self.errors.push(Error { - kind: ErrorKind::SemanticError("Bad cast".into()), + kind: ErrorKind::SemanticError("Bad type constructor".into()), meta, }); diff --git a/tests/in/glsl/expressions.frag b/tests/in/glsl/expressions.frag index 00ff8d31a2..58176f5aea 100644 --- a/tests/in/glsl/expressions.frag +++ b/tests/in/glsl/expressions.frag @@ -70,6 +70,10 @@ void testStructConstructor() { BST tree = BST(1); } +void testArrayConstructor() { + float tree[1] = float[1](0.0); +} + out vec4 o_color; void main() { o_color.rgba = vec4(1.0); diff --git a/tests/out/wgsl/expressions-frag.wgsl b/tests/out/wgsl/expressions-frag.wgsl index 452ff85d1c..f7514881ee 100644 --- a/tests/out/wgsl/expressions-frag.wgsl +++ b/tests/out/wgsl/expressions-frag.wgsl @@ -179,6 +179,11 @@ fn testStructConstructor() { } +fn testArrayConstructor() { + var tree1: array = array(0.0); + +} + fn main1() { let e1: vec4 = o_color; let e4: vec4 = vec4(1.0);