mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
* overloading byte->longint operator should be forbidden
This commit is contained in:
parent
574d6ed81a
commit
8572822119
22
tests/tbf/tb0141.pp
Normal file
22
tests/tbf/tb0141.pp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
{ This should not be allowed, it creates an infinite loop.
|
||||||
|
The loop can be solved using word() typecasts. But it is
|
||||||
|
to dangerous code to be allowed }
|
||||||
|
operator := (b:byte) l:longint;
|
||||||
|
begin
|
||||||
|
if b=0 then
|
||||||
|
l:=-1
|
||||||
|
else
|
||||||
|
l:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
l : longint;
|
||||||
|
b : byte;
|
||||||
|
begin
|
||||||
|
b:=0;
|
||||||
|
l:=b;
|
||||||
|
writeln(l);
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user