Re: [fpc-devel] ifthen bugs (maybe)

2016-02-04 Thread Jonas Maebe

On 04/02/16 05:22, Martin wrote:

   //writeln(b in ifthen( true , [1,2] , [3.4])); // internal error


Maybe that's not related to the fact that you use ifthen, but because 
you have [3.4] instead of [3,4]?



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] ifthen bugs (maybe)

2016-02-03 Thread Sven Barth
Am 04.02.2016 05:46 schrieb "Martin" :
>
> just found some issues
>
> Neither syntax works in constant evaluation.
> Not sure if they should, so asking here (the 2nd syntax is operator like,
so kind of expected it would)
>
> both cause an internal error trying to take the address of the returned
candidate.
> Then again this might not be a valid operation, but instead of internal
error it should then give a more proper error.
>
> program Project1;
> {$mode objfpc}
> const a = 1 + 2;
> //const a = ifthen(true, 1,2);
> //const a = if true then 1 else 2;
> var b: integer;
> var x : pointer;
> begin
>   //x :=  @( if false then b else b);  // internal error
>   //x :=  @( ifthen( false , b , b));  // internal error
>   writeln(a);
>   writeln(ptrint(x));
>   readln;
> end.
>
>
> Another internal error when using with the in operator.
> program Project1;
> {$mode objfpc}
> var b: integer;
> begin
>   b := 1;
>   writeln(b in [1,2] );
>   //writeln(b in ifthen( true , [1,2] , [3.4])); // internal error
>   //writeln(b in if true then [1,2] else [3.4]);  // internal error
>   readln;
> end.
>
>
> And this compiles, but nothing get incremented.
> If it should not work, then should it give an error?
> (such as "variable identifier expected" which you get when you try to
pass other not incrementable expressions )
>
> program Project1;
> {$mode objfpc}
> var b: integer;
> begin
>   b := 0;
>   writeln(b);
>   inc( if true then b else b );
>   writeln(b);
>   inc( ifthen( true ,b ,b ));
>   writeln(b);
>   readln;
> end.
>
> same with readln
>   readln( if true then b else b   );
>   writeln(b);
>   readln( ifthen( true ,b ,b ));
>   writeln(b);

Would you please report all three of them? I don't necessarily know the
best solution for problems 1 and 3, but internal errors definitely aren't
the answer...

Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] ifthen bugs (maybe)

2016-02-03 Thread Martin

just found some issues

Neither syntax works in constant evaluation.
Not sure if they should, so asking here (the 2nd syntax is operator 
like, so kind of expected it would)


both cause an internal error trying to take the address of the returned 
candidate.
Then again this might not be a valid operation, but instead of internal 
error it should then give a more proper error.


program Project1;
{$mode objfpc}
const a = 1 + 2;
//const a = ifthen(true, 1,2);
//const a = if true then 1 else 2;
var b: integer;
var x : pointer;
begin
  //x :=  @( if false then b else b);  // internal error
  //x :=  @( ifthen( false , b , b));  // internal error
  writeln(a);
  writeln(ptrint(x));
  readln;
end.


Another internal error when using with the in operator.
program Project1;
{$mode objfpc}
var b: integer;
begin
  b := 1;
  writeln(b in [1,2] );
  //writeln(b in ifthen( true , [1,2] , [3.4])); // internal error
  //writeln(b in if true then [1,2] else [3.4]);  // internal error
  readln;
end.


And this compiles, but nothing get incremented.
If it should not work, then should it give an error?
(such as "variable identifier expected" which you get when you try to 
pass other not incrementable expressions )


program Project1;
{$mode objfpc}
var b: integer;
begin
  b := 0;
  writeln(b);
  inc( if true then b else b );
  writeln(b);
  inc( ifthen( true ,b ,b ));
  writeln(b);
  readln;
end.

same with readln
  readln( if true then b else b   );
  writeln(b);
  readln( ifthen( true ,b ,b ));
  writeln(b);

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel