pastojs: fixed await on as operator

This commit is contained in:
mattias 2020-11-15 23:13:34 +00:00
parent 75d759c763
commit c3bdbfcd6e
3 changed files with 10 additions and 3 deletions

View File

@ -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 }

View File

@ -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;

View File

@ -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