]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
error if a function is called from global scope opposed to crashing
authorDale Weiler <weilercdale@gmail.com>
Sat, 5 May 2018 19:38:12 +0000 (15:38 -0400)
committerDale Weiler <weilercdale@gmail.com>
Sat, 5 May 2018 19:38:12 +0000 (15:38 -0400)
parser.cpp

index c795e40a39c9c6dd6e8354b5a76e6d83ea394c0e..cc2b3589b4ab85b9ec1c08c59655947e43e8773b 100644 (file)
@@ -1188,6 +1188,12 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
 
 static bool parser_close_call(parser_t *parser, shunt *sy)
 {
+    if (!parser->function)
+    {
+        parseerror(parser, "cannot call functions from global scope");
+        return false;
+    }
+
     /* was a function call */
     ast_expression *fun;
     ast_value      *funval = nullptr;