]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
The problem was so subtle
[xonotic/gmqcc.git] / parser.c
index fc2ef35de879a5cb58d49793984650ff6332f3c5..e8760bb08344a5e07f2333f3e6eba5fe83f9c360 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -506,9 +506,11 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
             if (exprs[0]->vtype != exprs[1]->vtype ||
                (exprs[0]->vtype != TYPE_VECTOR && exprs[0]->vtype != TYPE_FLOAT) )
             {
-                compile_error(ctx, "invalid types used in expression: cannot add type %s and %s",
+                compile_error(ctx, "invalid types used in expression: cannot add type %s and %s (%s %s)",
                               type_name[exprs[0]->vtype],
-                              type_name[exprs[1]->vtype]);
+                              type_name[exprs[1]->vtype],
+                              asvalue[0]->name,
+                              asvalue[1]->name);
                 return false;
             }
             if (!(out = fold_op(parser->fold, op, exprs))) {
@@ -587,6 +589,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
                 }
             }
             break;
+
         case opid1('/'):
             if (exprs[1]->vtype != TYPE_FLOAT) {
                 ast_type_to_string(exprs[0], ty1, sizeof(ty1));
@@ -595,21 +598,9 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
                 return false;
             }
             if (!(out = fold_op(parser->fold, op, exprs))) {
-                if (exprs[0]->vtype == TYPE_FLOAT) 
+                if (exprs[0]->vtype == TYPE_FLOAT)
                     out = (ast_expression*)ast_binary_new(ctx, INSTR_DIV_F, exprs[0], exprs[1]);
-                else if (exprs[0]->vtype == TYPE_VECTOR) {
-                    out = (ast_expression*)ast_binary_new (
-                                ctx,
-                                INSTR_MUL_VF,
-                                exprs[0],
-                                (ast_expression*)ast_binary_new(
-                                    ctx,
-                                    INSTR_DIV_F,
-                                    (ast_expression*)parser->fold->imm_float[1],
-                                    exprs[1]
-                                )
-                    );
-                } else {
+                else {
                     ast_type_to_string(exprs[0], ty1, sizeof(ty1));
                     ast_type_to_string(exprs[1], ty2, sizeof(ty2));
                     compile_error(ctx, "invalid types used in expression: cannot divide types %s and %s", ty1, ty2);