Ver código fonte

pastojs: fixed await on as operator

git-svn-id: trunk@47431 -
Mattias Gaertner 4 anos atrás
pai
commit
45fb1fcb44

+ 2 - 0
packages/fcl-passrc/src/pasresolveeval.pas

@@ -207,6 +207,7 @@ const
   nParamOfThisTypeCannotHaveDefVal = 3141;
   nClassTypesAreNotRelatedXY = 3142;
   nDirectiveXNotAllowedHere = 3143;
+  nAwaitWithoutPromise = 3144;
 
   // using same IDs as FPC
   nVirtualMethodXHasLowerVisibility = 3250; // was 3050
@@ -361,6 +362,7 @@ resourcestring
   sParamOfThisTypeCannotHaveDefVal = 'Parameters of this type cannot have default values';
   sClassTypesAreNotRelatedXY = 'Class types "%s" and "%s" are not related';
   sDirectiveXNotAllowedHere = 'Directive "%s" not allowed here';
+  sAwaitWithoutPromise = 'Await without promise';
 
 type
   { TResolveData - base class for data stored in TPasElement.CustomData }

+ 3 - 1
packages/fcl-passrc/src/pasresolver.pp

@@ -4849,7 +4849,9 @@ begin
     begin
     Bin:=TBinaryExpr(El);
     if Bin.OpCode=eopSubIdent then
-      El:=Bin.right;
+      El:=Bin.right
+    else
+      exit(nil);
     end;
   if (El is TPrimitiveExpr) and (TPrimitiveExpr(El).Kind=pekIdent) then
     Result:=El;

+ 5 - 2
packages/pastojs/src/fppas2js.pp

@@ -5878,9 +5878,10 @@ end;
 
 function TPas2JSResolver.BI_AWait_OnGetCallCompatibility(
   Proc: TResElDataBuiltInProc; Expr: TPasExpr; RaiseOnError: boolean): integer;
-// await(const Expr: T): T
 // await(T; p: TJSPromise): T;
 // await(AsyncProc);
+// await(Proc);
+// await(const Expr: T): T
 const
   Signature2 = 'function await(aType,TJSPromise):aType';
 var
@@ -6058,7 +6059,9 @@ begin
         Exclude(Ref.Flags,rrfNoImplicitCallWithoutParams);
         Include(Ref.Flags,rrfImplicitCallWithoutParams);
         end;
-      end;
+      end
+    else
+      LogMsg(20201116000324,mtHint,nAwaitWithoutPromise,sAwaitWithoutPromise,[],Param);
     end;
 
   if length(P)>1 then