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