[glsl-in] Allow array constructors

This commit is contained in:
João Capucho 2021-09-21 22:29:39 +01:00 committed by Dzmitry Malyshau
parent 70db5f681d
commit 160ab82fee
3 changed files with 11 additions and 2 deletions

View File

@ -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,
});

View File

@ -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);

View File

@ -179,6 +179,11 @@ fn testStructConstructor() {
}
fn testArrayConstructor() {
var tree1: array<f32,1> = array<f32,1>(0.0);
}
fn main1() {
let e1: vec4<f32> = o_color;
let e4: vec4<f32> = vec4<f32>(1.0);