mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 14:59:32 +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;
|
||||
begin
|
||||
result:=nil;
|
||||
|
||||
{ constant evaluation }
|
||||
if (left.nodetype=ordconstn) then
|
||||
begin
|
||||
@ -400,6 +401,15 @@ implementation
|
||||
typecheckpass(t);
|
||||
result:=t;
|
||||
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;
|
||||
|
||||
|
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