From 19c2e948b91bc35cb0ef007cd0f2379e8906afd4 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 3 Oct 2022 10:26:09 +0200 Subject: [PATCH] * nil =/<> dyn. array is a valid expression, so isbinaryoperatoroverloadable needs to take care of it, resolves #39933 (cherry picked from commit 2396b36c21c58a00b1a2e49b288393470de5cf88) --- compiler/htypechk.pas | 3 ++- tests/webtbs/tw39933.pp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw39933.pp diff --git a/compiler/htypechk.pas b/compiler/htypechk.pas index 330c5203a2..071ea4a25b 100644 --- a/compiler/htypechk.pas +++ b/compiler/htypechk.pas @@ -459,7 +459,8 @@ implementation ) or ( (lt=niln) and - (rd.typ in [procvardef,procdef,classrefdef]) and + ((rd.typ in [procvardef,procdef,classrefdef]) or + (is_dynamic_array(rd))) and (treetyp in identity_operators) ) or ( diff --git a/tests/webtbs/tw39933.pp b/tests/webtbs/tw39933.pp new file mode 100644 index 0000000000..b8da6256df --- /dev/null +++ b/tests/webtbs/tw39933.pp @@ -0,0 +1,13 @@ +{ %norun } +program Project1; + +{$mode delphi} + +var a: TArray; + +begin + writeln ( a = nil ); + writeln ( a <> nil ); + writeln ( nil = a ); // project1.lpr(10,17) Error: Operator is not overloaded: "Pointer" = "TArray$1$crc9F312717" + writeln ( nil <> a ); // project1.lpr(11,17) Error: Operator is not overloaded: "Pointer" = "TArray$1$crc9F312717" +end.