]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
an = before an { is also always required when the declared variable is not a function...
[xonotic/gmqcc.git] / parser.c
index 7034e64c7314ede34e1d65878c7b71c746efa40e..506f8d201fd812fccafce45c03930a29b5c178af 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5623,7 +5623,7 @@ skipvar:
             }
         }
 
-        if (parser->tok != '{') {
+        if (parser->tok != '{' || var->expression.vtype != TYPE_FUNCTION) {
             if (parser->tok != '=') {
                 parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
                 break;
@@ -5639,11 +5639,11 @@ skipvar:
         }
 
         if (parser->tok == '#') {
-            ast_function *func        = NULL;
-            ast_value    *number      = NULL;
-            float         fractional  = 0;
-            float         integral    = 0;
-            int           builtin_num = 0;
+            ast_function *func   = NULL;
+            ast_value    *number = NULL;
+            float         fractional;
+            float         integral;
+            int           builtin_num;
 
             if (localblock) {
                 parseerror(parser, "cannot declare builtins within functions");
@@ -5689,7 +5689,9 @@ skipvar:
 
                 /* we only want the integral part anyways */
                 builtin_num = integral;
-            } else if (parser->tok != TOKEN_INTCONST) {
+            } else if (parser->tok == TOKEN_INTCONST) {
+                builtin_num = parser_token(parser)->constval.i;
+            } else {
                 parseerror(parser, "builtin number must be a compile time constant");
                 break;
             }
@@ -5709,9 +5711,7 @@ skipvar:
                 }
                 vec_push(parser->functions, func);
 
-                func->builtin = -((OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS))
-                                    ? builtin_num
-                                    : parser_token(parser)->constval.i) - 1;
+                func->builtin = -builtin_num-1;
             }
 
             if (OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS)