From 8a8699ab6a5b50fdfc4d40beabfb2158baa2dc6f Mon Sep 17 00:00:00 2001 From: Henrique Gottardi Werlang Date: Fri, 1 Dec 2023 16:24:06 -0300 Subject: [PATCH] Fix for function Val to validate the parameter count of the function. --- packages/pastojs/src/fppas2js.pp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/pastojs/src/fppas2js.pp b/packages/pastojs/src/fppas2js.pp index 0d9338885f..b106aaae4f 100644 --- a/packages/pastojs/src/fppas2js.pp +++ b/packages/pastojs/src/fppas2js.pp @@ -5882,19 +5882,24 @@ var C: TClass; begin Result:=inherited; - Params:=TParamsExpr(Expr); - Param:=Params.Params[1]; - ComputeElement(Param,ParamResolved,[]); - Result:=cIncompatible; - bt:=ParamResolved.BaseType; - if bt=btRange then - bt:=ParamResolved.SubType; - if bt=btContext then - begin - C:=ParamResolved.LoTypeEl.ClassType; - if (C=TPasEnumType) or (C=TPasRangeType) then - Result:=cExact - end; + + if CheckBuiltInMinParamCount(Proc, Expr, 3, RaiseOnError) then + begin + Params:=TParamsExpr(Expr); + Param:=Params.Params[1]; + ComputeElement(Param,ParamResolved,[]); + Result:=cIncompatible; + bt:=ParamResolved.BaseType; + if bt=btRange then + bt:=ParamResolved.SubType; + if bt=btContext then + begin + C:=ParamResolved.LoTypeEl.ClassType; + if (C=TPasEnumType) or (C=TPasRangeType) then + Result:=cExact + end; + end; + if Result=cIncompatible then exit(CheckRaiseTypeArgNo(20181214142349,2,Param,ParamResolved, 'enum variable',RaiseOnError));