View Issue Details

IDProjectCategoryView StatusLast Update
0037760FPCPackagespublic2020-09-18 16:31
ReporterJoe care Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86-64OSWin64 
Product Version3.3.1 
Target Version4.0.0Fixed in Version3.3.1 
Summary0037760: fcl-passrc PasWrite writes ';' before else in if then else-blocks.
DescriptionWhen parsing a program with an if-then-else construct and using paswrite to write it again.
these are semicolons (';') in front of the else command, resulting that the written program does not compile anymore.
Steps To ReproduceParse with fcl-passrc:
begin if true then write('true')else write('false'); end.
Paswrite writes:
program test2;


begin
  if True then
    write('true');

  else
    write('false');
    ;
end.
Additional InformationHave not found the right place for a patch, will eventually provide one ...
Tagsfcl-passrc
Fixed in Revision46884
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Colin Haywood

2020-09-17 05:10

reporter   ~0125586

If this tool always splits up if statements onto multiple lines, then perhaps a good fix would be to get it to always put begin/end around the statements to be executed (the writeln's here), which helps people avoid the classic bug

if something then
    do_this_conditionally();
    do_this_conditionally_too(); // nope, it does this always

when another line is inserted later.

That extra semicolon before the "end." looks rather out-of-place too.

Michael Van Canneyt

2020-09-17 10:21

administrator   ~0125588

Fixed in 46884. Also remove spurious ; after else block.

Michael Van Canneyt

2020-09-17 10:23

administrator   ~0125589

Ah, I just see Colin's remark. Yes, this is just how I fixed it.

Joe care

2020-09-18 16:23

reporter   ~0125615

Now I get nested begin and ends. between If and else so:
[code] // PasWrite line 1258ff
    IncIndent;
    if AIfElse.IfBranch is TPasImplBeginBlock then
      WriteImplBlock(TPasImplBeginBlock(AIfElse.IfBranch))
    else
      WriteImplElement(AIfElse.IfBranch, False);
    DecIndent;
[/code]
So if there is already a begin...end only the inner block (the commands in the block) is/are written.

Joe care

2020-09-18 16:26

reporter   ~0125616

Patch appended ...
paswrite.patch (515 bytes)   
Index: paswrite.pp
===================================================================
--- paswrite.pp	(Revision 46888)
+++ paswrite.pp	(Arbeitskopie)
@@ -1256,7 +1256,10 @@
     if DoBeginEnd then
       AddLn('begin');
     IncIndent;
-    WriteImplElement(AIfElse.IfBranch, False);
+    if AIfElse.IfBranch is TPasImplBeginBlock then
+      WriteImplBlock(TPasImplBeginBlock(AIfElse.IfBranch))
+    else
+      WriteImplElement(AIfElse.IfBranch, False);
     DecIndent;
     if DoBeginEnd then
       begin
paswrite.patch (515 bytes)   

Michael Van Canneyt

2020-09-18 16:31

administrator   ~0125617

Fixed in 46889.

I just saw your patch as I was opening the bugreport to mark it fixed... I should learn to wait ;-)

Issue History

Date Modified Username Field Change
2020-09-16 21:12 Joe care New Issue
2020-09-16 21:12 Joe care Tag Attached: fcl-passrc
2020-09-17 05:10 Colin Haywood Note Added: 0125586
2020-09-17 10:21 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-09-17 10:21 Michael Van Canneyt Status new => resolved
2020-09-17 10:21 Michael Van Canneyt Resolution open => fixed
2020-09-17 10:21 Michael Van Canneyt Fixed in Revision => 46884
2020-09-17 10:21 Michael Van Canneyt FPCTarget => -
2020-09-17 10:21 Michael Van Canneyt Note Added: 0125588
2020-09-17 10:22 Michael Van Canneyt Fixed in Version => 3.3.1
2020-09-17 10:22 Michael Van Canneyt Target Version => 4.0.0
2020-09-17 10:22 Michael Van Canneyt FPCTarget - => 3.2.2
2020-09-17 10:23 Michael Van Canneyt Note Added: 0125589
2020-09-18 16:23 Joe care Status resolved => feedback
2020-09-18 16:23 Joe care Resolution fixed => open
2020-09-18 16:23 Joe care Note Added: 0125615
2020-09-18 16:26 Joe care Note Added: 0125616
2020-09-18 16:26 Joe care File Added: paswrite.patch
2020-09-18 16:26 Joe care Status feedback => assigned
2020-09-18 16:31 Michael Van Canneyt Status assigned => resolved
2020-09-18 16:31 Michael Van Canneyt Resolution open => fixed
2020-09-18 16:31 Michael Van Canneyt Note Added: 0125617