]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
The problem was so subtle
authorDale Weiler <killfieldengine@gmail.com>
Wed, 31 Jul 2013 18:53:00 +0000 (18:53 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 31 Jul 2013 18:53:00 +0000 (18:53 +0000)
fold.c
parser.c

diff --git a/fold.c b/fold.c
index ad264e737c98a49663365cee89bdeaf2263aeba9..884e039969f569e983f87a37ba3387b5893f8155 100644 (file)
--- a/fold.c
+++ b/fold.c
@@ -383,7 +383,7 @@ static GMQCC_INLINE ast_expression *fold_op_sub(fold_t *fold, ast_value *a, ast_
 
 static GMQCC_INLINE ast_expression *fold_op_mul(fold_t *fold, ast_value *a, ast_value *b) {
     if (isfloat(a)) {
 
 static GMQCC_INLINE ast_expression *fold_op_mul(fold_t *fold, ast_value *a, ast_value *b) {
     if (isfloat(a)) {
-        if (isfloat(b)) {
+        if (isvector(b)) {
             if (fold_can_2(a, b))
                 return fold_constgen_vector(fold, vec3_mulvf(fold_immvalue_vector(b), fold_immvalue_float(a)));
         } else {
             if (fold_can_2(a, b))
                 return fold_constgen_vector(fold, vec3_mulvf(fold_immvalue_vector(b), fold_immvalue_float(a)));
         } else {
@@ -585,5 +585,6 @@ ast_expression *fold_op(fold_t *fold, const oper_info *info, ast_expression **op
         case opid2('=','='):     return fold_op_cmp    (fold, a, b, false);
         case opid2('~','P'):     return fold_op_bnot   (fold, a);
     }
         case opid2('=','='):     return fold_op_cmp    (fold, a, b, false);
         case opid2('~','P'):     return fold_op_bnot   (fold, a);
     }
+    compile_error(fold_ctx(fold), "internal error: attempted to constant for unsupported operator");
     return NULL;
 }
     return NULL;
 }
index 16613908e3034ac6a3b3599e33a8c0c7a38be941..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) )
             {
             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[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))) {
                 return false;
             }
             if (!(out = fold_op(parser->fold, op, exprs))) {