diff --git a/.gitattributes b/.gitattributes index 8a89c5d311..abc922146f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6017,6 +6017,7 @@ tests/webtbf/tw4777.pp svneol=native#text/plain tests/webtbf/tw4778a.pp svneol=native#text/plain tests/webtbf/tw4781a.pp svneol=native#text/plain tests/webtbf/tw4781b.pp svneol=native#text/plain +tests/webtbf/tw4913.pp -text tests/webtbf/uw0744.pp svneol=native#text/plain tests/webtbf/uw0840a.pp svneol=native#text/plain tests/webtbf/uw0840b.pp svneol=native#text/plain diff --git a/compiler/nmem.pas b/compiler/nmem.pas index b0cecdefa5..80d69da487 100644 --- a/compiler/nmem.pas +++ b/compiler/nmem.pas @@ -676,9 +676,10 @@ implementation { maybe type conversion for the index value, but do not convert enums,booleans,char } - if (right.resulttype.def.deftype<>enumdef) and - not(is_char(right.resulttype.def) or is_widechar(right.resulttype.def)) and - not(is_boolean(right.resulttype.def)) then + if ((right.resulttype.def.deftype<>enumdef) and + not(is_char(right.resulttype.def) or is_widechar(right.resulttype.def)) and + not(is_boolean(right.resulttype.def))) or + (left.resulttype.def.deftype <> arraydef) then begin inserttypeconv(right,sinttype); end; diff --git a/tests/webtbf/tw4913.pp b/tests/webtbf/tw4913.pp new file mode 100644 index 0000000000..6bde8874cb --- /dev/null +++ b/tests/webtbf/tw4913.pp @@ -0,0 +1,22 @@ +{ %fail } + +{ Source provided for Free Pascal Bug Report 4913 } +{ Submitted by "Vinzent Hoefler" on 2006-03-17 } +{ e-mail: ada.rocks@jlfencey.com } +const + Some_String : String = '0123456789'; + +type + Some_Enum = (Zero, One, Two, Three); + +var + i : Some_Enum; + +begin + WriteLn (Some_String[2]); // Should fail if "Some_String = '...'"; + WriteLn (Some_String[Two]); // Should fail with type error. + + i := Three; + WriteLn (Some_String[i]); +end. +