mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 08:59:27 +02:00
fcl-passrc, pastojs: fixed crash on evaluating ord(int), #39260
This commit is contained in:
parent
29adfc18ff
commit
7ec6d9e3c1
@ -19450,7 +19450,8 @@ begin
|
||||
try
|
||||
Evaluated:=fExprEvaluator.OrdValue(Value,Params);
|
||||
finally
|
||||
ReleaseEvalValue(Value);
|
||||
if Evaluated<>Value then
|
||||
ReleaseEvalValue(Value);
|
||||
end;
|
||||
if Proc=nil then ;
|
||||
end;
|
||||
|
@ -198,6 +198,7 @@ begin
|
||||
Inc(FErrorCount);
|
||||
if aContext.Error is EParserError then
|
||||
FLastErrorNumber:=EParserError(aContext.Error).ErrNo;
|
||||
if Allow then ;
|
||||
end;
|
||||
|
||||
procedure TTestParser.SetupParser;
|
||||
|
@ -637,8 +637,6 @@ begin
|
||||
end;
|
||||
|
||||
procedure TTestConstParser.TestConstErrorRecovery;
|
||||
Var
|
||||
D : String;
|
||||
begin
|
||||
Add('Const');
|
||||
Add(' A : 1;');
|
||||
|
@ -13640,16 +13640,16 @@ function TPasToJSConverter.ConvertBuiltIn_Ord(El: TParamsExpr;
|
||||
Result:=nil;
|
||||
OrdValue:=nil;
|
||||
ParamValue:=aResolver.Eval(Param,[]);
|
||||
if ParamValue=nil then exit;
|
||||
try
|
||||
if ParamValue<>nil then
|
||||
OrdValue:=aResolver.ExprEvaluator.OrdValue(ParamValue,El);
|
||||
if OrdValue=ParamValue then
|
||||
ParamValue:=nil;
|
||||
if OrdValue<>nil then
|
||||
begin
|
||||
OrdValue:=aResolver.ExprEvaluator.OrdValue(ParamValue,El);
|
||||
if OrdValue<>nil then
|
||||
begin
|
||||
// ord(constant) -> constant
|
||||
Result:=ConvertConstValue(OrdValue,AContext,El);
|
||||
exit;
|
||||
end;
|
||||
// ord(constant) -> constant
|
||||
Result:=ConvertConstValue(OrdValue,AContext,El);
|
||||
exit;
|
||||
end;
|
||||
finally
|
||||
ReleaseEvalValue(ParamValue);
|
||||
|
@ -7191,6 +7191,7 @@ begin
|
||||
' Enum: byte;',
|
||||
' Enums: tenums;',
|
||||
'begin',
|
||||
' Enum:=ord(1);',
|
||||
' Enums:=[];',
|
||||
' Enums:=[0];',
|
||||
' Enums:=[1..2];',
|
||||
@ -7206,6 +7207,7 @@ begin
|
||||
'this.Enums = {};',
|
||||
'']),
|
||||
LinesToStr([
|
||||
'$mod.Enum = 1;',
|
||||
'$mod.Enums = {};',
|
||||
'$mod.Enums = rtl.createSet(0);',
|
||||
'$mod.Enums = rtl.createSet(null, 1, 2);',
|
||||
|
Loading…
Reference in New Issue
Block a user