mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
+ in on an empty set is always false, resolves #40745
This commit is contained in:
parent
484dab553b
commit
e412f6be55
@ -350,6 +350,7 @@ implementation
|
|||||||
t : tnode;
|
t : tnode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
|
|
||||||
{ constant evaluation }
|
{ constant evaluation }
|
||||||
if (left.nodetype=ordconstn) then
|
if (left.nodetype=ordconstn) then
|
||||||
begin
|
begin
|
||||||
@ -400,6 +401,15 @@ implementation
|
|||||||
typecheckpass(t);
|
typecheckpass(t);
|
||||||
result:=t;
|
result:=t;
|
||||||
exit;
|
exit;
|
||||||
|
end
|
||||||
|
{ ... in [] is always false }
|
||||||
|
else if is_emptyset(right) and
|
||||||
|
not(might_have_sideeffects(left,[mhs_exceptions])) then
|
||||||
|
begin
|
||||||
|
t:=cordconstnode.create(1, pasbool1type, false);
|
||||||
|
typecheckpass(t);
|
||||||
|
result:=t;
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
17
tests/webtbs/tw40745.pp
Normal file
17
tests/webtbs/tw40745.pp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
program test;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
TSetOfChar = set of char;
|
||||||
|
TMyObject=class
|
||||||
|
class function Method(setofchar: TSetOfChar): Boolean; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TMyObject.Method(setofchar: TSetOfChar): Boolean;
|
||||||
|
var sym: char=#0;
|
||||||
|
begin
|
||||||
|
Result:=sym in setofchar;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
TMyObject.Method([]);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user