Przeglądaj źródła

Fix internal compiler error on declaring methods in POINTER TO RECORD declaration

Closes #51
Vladislav Folts 4 lat temu
rodzic
commit
cdf482fc86
3 zmienionych plików z 9 dodań i 0 usunięć
  1. BIN
      bin/compiled.zip
  2. 3 0
      src/eberon/EberonContextType.ob
  3. 6 0
      test/test_unit_eberon.js

BIN
bin/compiled.zip


+ 3 - 0
src/eberon/EberonContextType.ob

@@ -91,6 +91,9 @@ VAR
     result: Object.PType;
 BEGIN
     IF msg IS MethodDeclMsg THEN 
+        IF SELF.declaration.id = NIL THEN
+            Errors.raise("cannot declare methods for anonymous records (POINTER TO RECORD)");
+        END;
         methodType <- msg.type;
         boundType <- SELF.type(EberonRecord.PRecord);
         id <- msg.id.id();

+ 6 - 0
test/test_unit_eberon.js

@@ -93,6 +93,12 @@ exports.suite = {
          ["STRING: INTEGER", "'STRING' already declared"]
          )
     ),
+"method declaration for pointer type": testWithGrammar(
+    grammar.typeDeclaration,
+    pass(),
+    fail(["PT = POINTER TO RECORD PROCEDURE p() END",
+          "cannot declare methods for anonymous records (POINTER TO RECORD)"])
+),
 "abstract method declaration": testWithContext(
     context(grammar.declarationSequence, 
             "TYPE T = RECORD PROCEDURE p() END;"