Преглед на файлове

Fix bug where MAIN_FUNCTION could be declared without return type = VOID

Lucas Souza преди 6 години
родител
ревизия
213a80ff9f
променени са 1 файла, в които са добавени 6 реда и са изтрити 1 реда
  1. 6 1
      js/ast/ivprogParser.js

+ 6 - 1
js/ast/ivprogParser.js

@@ -377,7 +377,12 @@ export class IVProgParser {
     }
     this.consumeNewLines();
     const commandsBlock = this.parseCommandBlock();
-    return new Commands.Function(functionID, returnType, formalParams, commandsBlock);
+    const func = new Commands.Function(functionID, returnType, formalParams, commandsBlock);
+    if (functionID === null && !func.isMain) {
+      // TODO: better error message
+      throw new Error("");
+    }
+    return func;
   }
 
   /*