Browse Source

pas2js: fixed crash on class function

mattias 5 years ago
parent
commit
0542edda2a
1 changed files with 3 additions and 0 deletions
  1. 3 0
      compiler/packages/pastojs/src/fppas2js.pp

+ 3 - 0
compiler/packages/pastojs/src/fppas2js.pp

@@ -2960,6 +2960,7 @@ begin
     exit(false); // there is no overload
     exit(false); // there is no overload
 
 
   if (El.ClassType=TPasClassFunction)
   if (El.ClassType=TPasClassFunction)
+      and (El.Parent.ClassType=TPasClassType)
       and (TPas2JSClassScope(TPasClassType(El.Parent).CustomData).NewInstanceFunction=El) then
       and (TPas2JSClassScope(TPasClassType(El.Parent).CustomData).NewInstanceFunction=El) then
     begin
     begin
     Duplicate:=GetDuplicate;
     Duplicate:=GetDuplicate;
@@ -3165,6 +3166,8 @@ var
   Scope: TPasIdentifierScope;
   Scope: TPasIdentifierScope;
 begin
 begin
   i:=FOverloadScopes.Count-1;
   i:=FOverloadScopes.Count-1;
+  if i<0 then
+    RaiseInternalError(20200723125456);
   Scope:=TPasIdentifierScope(FOverloadScopes[i]);
   Scope:=TPasIdentifierScope(FOverloadScopes[i]);
   if Scope.ClassType=TPas2JSOverloadSkipScope then
   if Scope.ClassType=TPas2JSOverloadSkipScope then
     Scope.Free;
     Scope.Free;