From: Wolfgang Bumiller Date: Wed, 29 May 2013 14:58:18 +0000 (+0200) Subject: return assignment factorial test X-Git-Tag: v0.3.0~151^2~34 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5aba29006bdd32442ee2ed3e4c9c6eaf911a806b;p=xonotic%2Fgmqcc.git return assignment factorial test --- diff --git a/parser.c b/parser.c index 27c694d..d9be036 100644 --- a/parser.c +++ b/parser.c @@ -2955,6 +2955,11 @@ static bool parse_return(parser_t *parser, ast_block *block, ast_expression **ou return false; } + if (parser->tok != ';') + parseerror(parser, "missing semicolon after return assignment"); + else if (!parser_next(parser)) + parseerror(parser, "parse error after return assignment"); + *out = var; return true; } diff --git a/tests/rassign.qc b/tests/rassign.qc index 7e3d0e6..69ec31c 100644 --- a/tests/rassign.qc +++ b/tests/rassign.qc @@ -9,7 +9,7 @@ vector f_vector() { foo.x = f_float(); foo.y = f_float(); foo.z = f_float(); - + return = foo; return; } @@ -20,8 +20,16 @@ string f_string() { return; } +float factorial(float n) { + if (n == 0) return = 1; + else return = n * factorial(n - 1); + + return; +} + void main() { print(ftos(f_float()), "\n"); // 200.0f print(vtos(f_vector()), "\n"); // '1 2 3' print(f_string(), "\n"); // world + print(ftos(factorial(4)), "\n"); // 24 } diff --git a/tests/rassign.tmpl b/tests/rassign.tmpl index 63642aa..f169c82 100644 --- a/tests/rassign.tmpl +++ b/tests/rassign.tmpl @@ -5,3 +5,4 @@ C: -freturn-assignments M: 200 M: '200 200 200' M: world +M: 24