return assignment factorial test

This commit is contained in:
Wolfgang Bumiller 2013-05-29 16:58:18 +02:00
parent 9167de1631
commit 5aba29006b
3 changed files with 15 additions and 1 deletions

View file

@ -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;
}

View file

@ -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
}

View file

@ -5,3 +5,4 @@ C: -freturn-assignments
M: 200
M: '200 200 200'
M: world
M: 24