diff --git a/.gitattributes b/.gitattributes index 17ab65025e..0b4361a6c3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7239,6 +7239,7 @@ tests/webtbs/tw7104.pp svneol=native#text/plain tests/webtbs/tw7143.pp -text tests/webtbs/tw7161.pp svneol=native#text/plain tests/webtbs/tw7195.pp svneol=native#text/plain +tests/webtbs/tw7227.pp svneol=native#text/plain tests/webtbs/ub1873.pp svneol=native#text/plain tests/webtbs/ub1883.pp svneol=native#text/plain tests/webtbs/uw0555.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index b5f1aecc16..5efea4b529 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -586,8 +586,11 @@ implementation arraydef : begin - { open array is also compatible with a single element of its base type } + { open array is also compatible with a single element of its base type. + the extra check for deftyp is needed because equal defs can also return + true if the def types are not the same, for example with dynarray to pointer. } if is_open_array(def_to) and + (def_to.deftype=tarraydef(def_to).elementtype.def.deftype) and equal_defs(def_from,tarraydef(def_to).elementtype.def) then begin doconv:=tc_equal; diff --git a/tests/webtbs/tw7227.pp b/tests/webtbs/tw7227.pp new file mode 100644 index 0000000000..22a86f8d3f --- /dev/null +++ b/tests/webtbs/tw7227.pp @@ -0,0 +1,33 @@ + +program openarray; +{$ifdef fpc}{$mode delphi}{$endif} +type + PDouble = ^Double; + +function CheckValues(values : array of PDouble) : boolean; +var i : integer; +begin + Result := True; + for i := Low(values) to High(values) do + if values[i]^ = 0 then + Result := False; +end; + +var values : array of PDouble; + i : integer; +begin + SetLength(values, 5); + for i := 0 to High(values) do + begin + New(values[i]); + values[i]^ := i+1; + end; + + for i := 0 to High(values) do + writeln(values[i]^); + + if CheckValues(values) then + WriteLn('OK') + else + writeln('not OK'); +end.