* give again an error for "in" operations on incompatible set

elements/sets after introduction of support for "longint in set"

git-svn-id: trunk@6885 -
This commit is contained in:
Jonas Maebe 2007-03-16 19:44:43 +00:00
parent 07d97e2916
commit 428306051f
3 changed files with 33 additions and 0 deletions

1
.gitattributes vendored
View File

@ -7191,6 +7191,7 @@ tests/webtbf/tw8150f.pp svneol=native#text/plain
tests/webtbf/tw8150g.pp svneol=native#text/plain
tests/webtbf/tw8264a.pp svneol=native#text/plain
tests/webtbf/tw8398.pp svneol=native#text/plain
tests/webtbf/tw8528.pp svneol=native#text/plain
tests/webtbf/uw0744.pp svneol=native#text/plain
tests/webtbf/uw0840a.pp svneol=native#text/plain
tests/webtbf/uw0840b.pp svneol=native#text/plain

View File

@ -268,6 +268,22 @@ implementation
inserttypeconv(left,s32inttype)
else
inserttypeconv(left,u32inttype);
end
else if assigned(tsetdef(right.resultdef).elementdef) and
not(is_integer(tsetdef(right.resultdef).elementdef) and
is_integer(left.resultdef)) then
begin
{ Dummy type conversion to check things like }
{ 'char in set_of_byte'. Can't use is_subequal because that }
{ will fail for 'widechar in set_of_char' }
{ Can't use the type conversion for integers because then }
{ "longint in set_of_byte" will give a range check error }
{ instead of false }
{ Use a copy of left in case the typeconv node would modify }
{ left directly (since we need the original left) }
t := ctypeconvnode.create(left.getcopy,tsetdef(right.resultdef).elementdef);
typecheckpass(t);
t.free;
end;
{ empty set then return false }

16
tests/webtbf/tw8528.pp Normal file
View File

@ -0,0 +1,16 @@
{ %fail }
program test;
{$mode objfpc}{$H+}
const
AllowedCharSet: set of Byte = [48..60];
var
s: string;
begin
s := 'test0';
if s[5] in AllowedCharSet then
Writeln('huh?');
end.