From 8c198adedc220ca6fc482d0999f95179030c294a 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: Mon, 25 May 2020 21:47:44 +0200 Subject: [PATCH] bug fix #2238 --- NETGenerator/NETGenerator.cs | 5 +++-- TestSuite/enum5.pas | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 TestSuite/enum5.pas diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 4fd0ed606..3d56fb550 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -3483,8 +3483,9 @@ namespace PascalABCCompiler.NETGenerator PushIntConst(il, i - 2 - rank); ILGenerator ilb = this.il; - if (ti != null && ti.tp.IsValueType && !TypeFactory.IsStandType(ti.tp) && !ti.tp.IsEnum) - il.Emit(OpCodes.Ldelema, ti.tp); + if (ti != null && ti.tp.IsValueType && !TypeFactory.IsStandType(ti.tp) && (helper.IsConstructedGenericType(ti.tp) || ti.tp.IsGenericType || !ti.tp.IsEnum)) + if (!(ti.tp is EnumBuilder)) + il.Emit(OpCodes.Ldelema, ti.tp); this.il = il; exprs[i].visit(this); diff --git a/TestSuite/enum5.pas b/TestSuite/enum5.pas new file mode 100644 index 000000000..710f58cd6 --- /dev/null +++ b/TestSuite/enum5.pas @@ -0,0 +1,10 @@ +uses System; + +type + Enum = (A, B); + +begin + var arr := new ValueTuple[](new ValueTuple(A,B)); + assert(arr[0].Item1 = A); + assert(arr[0].Item2 = B); +end. \ No newline at end of file