diff --git a/src/front/glsl/ast.rs b/src/front/glsl/ast.rs index 4a55caa43..1247adcb1 100644 --- a/src/front/glsl/ast.rs +++ b/src/front/glsl/ast.rs @@ -485,12 +485,15 @@ impl<'function> Context<'function> { self.add_expression(Expression::Access { base, index }, body) }); - if let TypeInner::Pointer { .. } = *program.resolve_type(self, pointer, meta)? { - if !lhs { - return Ok(( - Some(self.add_expression(Expression::Load { pointer }, body)), - meta, - )); + if !lhs { + match *program.resolve_type(self, pointer, meta)? { + TypeInner::Pointer { .. } | TypeInner::ValuePointer { .. } => { + return Ok(( + Some(self.add_expression(Expression::Load { pointer }, body)), + meta, + )); + }, + _ => {}, } } diff --git a/src/front/glsl/parser_tests.rs b/src/front/glsl/parser_tests.rs index 6bf6f78bf..465163867 100644 --- a/src/front/glsl/parser_tests.rs +++ b/src/front/glsl/parser_tests.rs @@ -673,3 +673,21 @@ fn swizzles() { ) .unwrap_err(); } + +#[test] +fn vector_indexing() { + let mut entry_points = crate::FastHashMap::default(); + entry_points.insert("".to_string(), ShaderStage::Fragment); + + parse_program( + r#" + # version 450 + float main(int index) { + vec4 v = vec4(1.0, 2.0, 3.0, 4.0); + return v[index] + 1.0; + } + "#, + &entry_points, + ) + .unwrap(); +}