Browse Source

* better error recovery, resolves #36397

git-svn-id: trunk@43653 -
florian 5 years ago
parent
commit
ac6e4f59c6
3 changed files with 27 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 6 1
      compiler/pexpr.pas
  3. 20 0
      tests/webtbf/tw36397.pp

+ 1 - 0
.gitattributes

@@ -16100,6 +16100,7 @@ tests/webtbf/tw36223.pp svneol=native#text/pascal
 tests/webtbf/tw3626.pp svneol=native#text/plain
 tests/webtbf/tw3631.pp svneol=native#text/plain
 tests/webtbf/tw36377.pp svneol=native#text/pascal
+tests/webtbf/tw36397.pp -text svneol=native#text/pascal
 tests/webtbf/tw3643.pp svneol=native#text/plain
 tests/webtbf/tw3644.pp svneol=native#text/plain
 tests/webtbf/tw3662.pp svneol=native#text/plain

+ 6 - 1
compiler/pexpr.pas

@@ -1380,7 +1380,12 @@ implementation
                                  not(po_staticmethod in tcallnode(p1).procdefinition.procoptions) and
                                  (not assigned(current_structdef) or
                                   not def_is_related(current_structdef,structh)) then
-                                Message(parser_e_only_static_members_via_object_type);
+                                begin
+                                  p1.free;
+                                  p1:=cerrornode.create;
+                                  Message(parser_e_only_static_members_via_object_type);
+                                  exit;
+                                end;
                             end;
                           { in Java, constructors are not automatically inherited
                             -> calling a constructor from a parent type will create

+ 20 - 0
tests/webtbf/tw36397.pp

@@ -0,0 +1,20 @@
+{ %fail }
+program Project1;
+
+{$mode delphi}
+
+type
+  TTest = object
+    class procedure myproc;
+  end;
+
+  class procedure TTest.myproc;
+  begin
+  end;
+
+var
+  p: procedure;
+begin
+  p := TTest.myproc;
+end.
+