diff --git a/TestSuite/nullable18.pas b/TestSuite/nullable18.pas new file mode 100644 index 000000000..e1ad0be1b --- /dev/null +++ b/TestSuite/nullable18.pas @@ -0,0 +1,6 @@ +begin + var a := |default(integer?),nil,1|; + assert(a[1] = nil); + assert(a[0] = nil); + assert(a[2] = 1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 0958f3a2b..21eb03f53 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -3285,7 +3285,8 @@ namespace PascalABCCompiler.TreeConverter ret_type = types[i]; else if (tc == type_compare.non_comparable_type) { - AddError(lst[i].location, "UNCOMPARABLE_TYPES_IN_ARRAY_CONST"); + if (!can_convert_type(types[i], ret_type)) + AddError(lst[i].location, "UNCOMPARABLE_TYPES_IN_ARRAY_CONST"); } }