Ver código fonte

returns must be inside a function

Kajetan Johannes Hammerle 4 anos atrás
pai
commit
079563b3c7
1 arquivos alterados com 3 adições e 1 exclusões
  1. 3 1
      Compiler.c

+ 3 - 1
Compiler.c

@@ -277,7 +277,9 @@ static void cFunction() {
 }
 
 static void cReturn() {
-    if(returnIndex >= RETURN_BUFFER) {
+    if(varIndex == 0) {
+        cError("return without a function on line %d", line);
+    } else if(returnIndex >= RETURN_BUFFER) {
         cError("too much returns in function around line %d", line);
     }
     cAddOperation(OP_POP);