From c6b852f373d7dbdd5f4d0cc47a6bf9c6d0b0208c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 6 Oct 2019 12:38:27 +0200 Subject: [PATCH] bug fix #1502 --- NETGenerator/NETGenerator.cs | 3 +- TestSuite/CompilationSamples/PABCSystem.pas | 2 +- TestSuite/class3.pas | 39 ++++++++++++++++++++ _GenerateAllSetups.bat | 1 + _RebuildReleaseAndRunTests.bat | 1 + bin/TestRunner.exe | Bin 33280 -> 33280 bytes bin/TestRunner.pas | 24 +++--------- 7 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 TestSuite/class3.pas diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 005ee08ae..d6ad44a8a 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -9630,10 +9630,11 @@ namespace PascalABCCompiler.NETGenerator { is_dot_expr = false; } - if (init_call_awaited && !value.new_obj_awaited()) + if (init_call_awaited && !value.new_obj_awaited() && cnstr.DeclaringType != cur_type) { il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Call, cur_ti.init_meth); + //throw new Exception(cnstr.DeclaringType.Name+"-"+cur_meth.DeclaringType.Name); init_call_awaited = false; } } diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 3d0c1c010..7c1dbc897 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -9413,7 +9413,7 @@ end; /// Возвращает индекс последнего минимального элемента function LastIndexMin(Self: array of T): integer; extensionmethod; where T: System.IComparable; begin - Result := Self.LastIndexMin(Self.Count - 1); + Result := Self.LastIndexMin(Self.Length - 1); end; /// Возвращает индекс последнего минимального элемента в диапазоне [0,index-1] diff --git a/TestSuite/class3.pas b/TestSuite/class3.pas new file mode 100644 index 000000000..e17b48a9f --- /dev/null +++ b/TestSuite/class3.pas @@ -0,0 +1,39 @@ +type + t1=class + + public i1 := 1; + public i2 := 2; + public o: object := new Object; + + public constructor(i1, i2: integer); + begin + assert(o <> nil); + self.i1 := i1; + self.i2 := i2; + end; + + public constructor(i1: integer) := + Create(i1,6); + + end; + + t2 = class + a: array of integer := (1, 2, 3); + b: set of char := ['a', 'b', 'c']; + constructor(a: array of integer); + begin + assert('b' in b); + assert(self.a[0] = 1); + self.a := a; + end; + end; + + +begin + var o1 := new t1(3,4); + var o2 := new t1(5); + assert(o2.i1 = 5); + assert(o2.i2 = 6); + var o3 := new t2(Arr(4, 5, 6)); + assert(o3.a[0] = 4); +end. \ No newline at end of file diff --git a/_GenerateAllSetups.bat b/_GenerateAllSetups.bat index d2bbf277d..1be7acccc 100644 --- a/_GenerateAllSetups.bat +++ b/_GenerateAllSetups.bat @@ -45,6 +45,7 @@ TestRunner.exe 2 TestRunner.exe 3 TestRunner.exe 4 TestRunner.exe 5 +TestRunner.exe 6 cd ..\ReleaseGenerators call PascalABCNET_ALL.bat diff --git a/_RebuildReleaseAndRunTests.bat b/_RebuildReleaseAndRunTests.bat index 9ce4bc6de..d6fc274a9 100644 --- a/_RebuildReleaseAndRunTests.bat +++ b/_RebuildReleaseAndRunTests.bat @@ -28,6 +28,7 @@ TestRunner.exe 2 TestRunner.exe 3 TestRunner.exe 4 TestRunner.exe 5 +TestRunner.exe 6 cd .. GOTO EXIT diff --git a/bin/TestRunner.exe b/bin/TestRunner.exe index 5114254be0e6e53c6f7eb870248fadaa4f5ea348..9f504e384e66db287d676eeffd87956abaacb20e 100644 GIT binary patch delta 542 zcmZo@VQOe$n$W>y)<3aJj_Kc=iL1g`*UVvH@SkkRD8sXWfq{pCfguAZAT#+Qqt4_= zMs-G($&HNl3J-u{Am9PSObo0HXW|(c=GZVWFar5N%r-f&-e7Y8Q?w9!1dzw15jHtb zRDAMDk$Fgb84)H1K8Sij1||)d!g->9P$hC8CTw0O_C}pqfgyAAT)RR>mH?p6$p;T{_#K<=?Ow4ARy~`#t3Me++*!kZ!$b0?o*fa9E)9N?BDL=yIXVyPG7NiB}7zT9^ z0|;8`7#MIjD20n;-K?Wubn8JCYelY+fh!Mx9xXVdLhxc7=@MvLGA8 zHJX5?7L{`_6ljPsFmPEWP3Cv-6BpCq1`0D2C2|7An?X#ASfJ|3whjtd&Mn-2196M@1C(kQxRCA&~zVn1Mmc$Z%@2WaJx}&75WZi~@K0?{b$r*SSvj{&mwPl9zk)it;0D zL94x{gM0{#0tN