void ExpressionValidator::visit(BinaryExpression &binary)
{
if(!binary.type && binary.left->type && binary.right->type)
- error(binary, format("No matching operator '%s' found for '%s' and '%s'",
- binary.oper->token, binary.left->type->name, binary.right->type->name));
+ {
+ if(binary.oper->token[0]=='[')
+ error(binary, format("Can't index element of '%s' with '%s'",
+ binary.left->type->name, binary.right->type->name));
+ else
+ error(binary, format("No matching operator '%s' found for '%s' and '%s'",
+ binary.oper->token, binary.left->type->name, binary.right->type->name));
+ }
TraversingVisitor::visit(binary);
}
--- /dev/null
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in float scale;
+int main()
+{
+ gl_Position = position[scale];
+ gl_Position = scale[position];
+}
+
+/* Expected error:
+<test>:6: Can't index element of 'vec4' with 'float'
+<test>:7: Can't index element of 'float' with 'vec4'
+*/