From af1b9b85f42513a6366866fd7d8c6ce83304dfde Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Fri, 8 Jan 2021 14:49:07 +0100 Subject: [PATCH] #2393 --- TestSuite/errors/err0399.pas | 14 ++++++++++++++ TestSuite/implicitexplicit10.pas | 19 +++++++++++++++++++ TreeConverter/TreeRealization/types.cs | 4 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 TestSuite/errors/err0399.pas create mode 100644 TestSuite/implicitexplicit10.pas diff --git a/TestSuite/errors/err0399.pas b/TestSuite/errors/err0399.pas new file mode 100644 index 000000000..4ead506b7 --- /dev/null +++ b/TestSuite/errors/err0399.pas @@ -0,0 +1,14 @@ +type + t1 = class + static function operator implicit(o: T): t1; + where T: record; + begin end; + end; + + t2 = class end; + +procedure p1(q: t1) := exit; + +begin + p1(new t2);//Здесь теперь правильная ошибка: Нельзя преобразовать тип t2 к t1 +end. \ No newline at end of file diff --git a/TestSuite/implicitexplicit10.pas b/TestSuite/implicitexplicit10.pas new file mode 100644 index 000000000..3b8927901 --- /dev/null +++ b/TestSuite/implicitexplicit10.pas @@ -0,0 +1,19 @@ +var i: integer; +type + t1 = class + static function operator implicit(o: T): t1; + where T: record; + begin + i := 1; + end; + end; + + t2 = class(t1) end; + +procedure p1(q: t1) := exit; + +begin + //Ошибка: Невозможно инстанцировать, так как тип t2 не является размерным + p1(new t2); + assert(i = 0); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index d327591e1..7e7b91fbd 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2331,7 +2331,7 @@ namespace PascalABCCompiler.TreeRealization { if (ctn.IsPointer) continue; - fn = fn.get_instance(new List(new type_node[] { ctn }), true, null); + fn = fn.get_instance(new List(new type_node[] { ctn }), false, null); } } return fn; @@ -2373,7 +2373,7 @@ namespace PascalABCCompiler.TreeRealization ctn = (ctn as ref_type_node).pointed_type; if (ctn.IsPointer) continue; - fn = fn.get_instance(new List(new type_node[] { ctn }), true, null); + fn = fn.get_instance(new List(new type_node[] { ctn }), false, null); } } return fn;