pastojs: fixed multi add element position

git-svn-id: trunk@49122 -
(cherry picked from commit 204f2a3bc1)
This commit is contained in:
Mattias Gaertner 2021-04-05 10:28:52 +00:00 committed by Florian Klämpfl
parent fabb4b45f3
commit f90f5a390a
2 changed files with 11 additions and 4 deletions

View File

@ -9750,7 +9750,7 @@ begin
B:=ConvertExpression(SubBin.right,AContext);
if aResolver<>nil then
begin
aResolver.ComputeElement(El.right,RightResolved,Flags);
aResolver.ComputeElement(SubBin.right,RightResolved,Flags);
Result:=ConvertBinaryExpressionRes(SubBin,AContext,LeftResolved,RightResolved,A,B);
if (Result<>nil) then
begin
@ -9763,7 +9763,7 @@ begin
if Result=nil then
begin
// +
R:=TJSBinary(CreateElement(TJSAdditiveExpressionPlus,El));
R:=TJSBinary(CreateElement(TJSAdditiveExpressionPlus,SubBin));
R.A:=A; A:=nil;
R.B:=B; B:=nil;
Result:=R;

View File

@ -3314,8 +3314,10 @@ procedure TTestModule.TestMultiAdd;
begin
StartProgram(false);
Add([
'function Fly: string; external name ''fly'';',
'function TryEncodeDate(Year, Month, Day: Word): Boolean;',
'var Date: double;',
'var',
' Date: double;',
'begin',
' Result:=(Year>0) and (Year<10000) and',
' (Month >= 1) and (Month<=12) and',
@ -3324,7 +3326,10 @@ begin
'end;',
'var s: string;',
'begin',
' s:=''a''+''b''+''c''+''d'';']);
' s:=''a''+''b''+''c''+''d'';',
' s:=s+Fly+''e'';',
' s:=Fly+Fly+Fly;',
'']);
ConvertProgram;
CheckSource('TestMultiAdd',
LinesToStr([ // statements
@ -3339,6 +3344,8 @@ begin
'']),
LinesToStr([ // this.$main
'$mod.s = "a" + "b" + "c" + "d";',
'$mod.s = $mod.s + fly() + "e";',
'$mod.s = fly() + fly() + fly();',
'']));
end;