Lazarus

Free Pascal => FPC development => Topic started by: taazz on September 16, 2018, 05:16:33 am

Title: Bug Verification
Post by: taazz on September 16, 2018, 05:16:33 am
I would like to verify that the following is a bug or if not what I missunderstood.
Unit  :fpexprpars.pas
proc :TFPExpressionParser.Primitive
Line  : 1721 highlighted bellow.
Code: Pascal  [Select][+][-]
  1.     if TryStrToInt64(CurrentToken,I) then
  2.       Result:=TFPConstExpression.CreateInteger(I)
  3.     else
  4.       begin
  5.       Val(CurrentToken,X,C);
  6.       If (I=0) then
  7.         Result:=TFPConstExpression.CreateFloat(X)
  8.       else
  9.         ParserError(Format(SErrInvalidFloat,[CurrentToken]));
  10.       end;
  11.     end
  12.  
according my reading  skills I would expect the line to read If (C=0) then instead of I. Is my assumption correct?

PS:
  the code comes from a lazarus 1.8.4 64bit installation. So if its a bug I need confirmation that its still present in trunk before I report it.
Title: Re: Bug Verification
Post by: WooBean on September 16, 2018, 08:23:13 am
Hello  tazz,

in my opinion it is a bug and it is harmful when CurrentToken cannot be parsed to int64 nor float value. In such a case snipped line 9. "ParserError(Format(SErrInvalidFloat,[CurrentToken]));" is not called despite it should be - according to a common logic.


The bug, definitely

WooBean   
Title: Re: Bug Verification
Post by: zamtmn on September 16, 2018, 08:29:32 am
Yes, it present in trunk https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-base/src/fpexprpars.pp?view=markup

I confirm, this is a bug (typo)
Title: Re: Bug Verification
Post by: taazz on September 16, 2018, 01:56:50 pm
Thank you gentlemen, I'll report it later tonight if there is no active report on the subject.
TinyPortal © 2005-2018