mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-02-24 09:30:03 +00:00
'return' is now a valid statement outside of a function
lets us do some cool things later. also the repl can print returned values. eg. `return "hello world"` will print `<string> "hello world"` to the console
This commit is contained in:
@@ -1471,10 +1471,10 @@ static void functionDeclaration(CParseState *pstate)
|
||||
|
||||
static void returnStatement(CParseState *pstate)
|
||||
{
|
||||
if (pstate->compiler->type != FTYPE_FUNCTION && pstate->compiler->type != FTYPE_METHOD) {
|
||||
error(pstate, "Expected 'return' in function!");
|
||||
return;
|
||||
}
|
||||
// if (pstate->compiler->type != FTYPE_FUNCTION && pstate->compiler->type != FTYPE_METHOD) {
|
||||
// error(pstate, "Expected 'return' in function!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (blockFollow(pstate->current)) { // does this return have a value
|
||||
writeu8(pstate, OP_NIL);
|
||||
|
||||
Reference in New Issue
Block a user