This commit is contained in:
parent
f528ee0ad8
commit
af2bc0fda8
|
|
@ -3885,7 +3885,11 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
if (ti != null && ti.tp.IsValueType && !TypeFactory.IsStandType(ti.tp) && (helper.IsConstructedGenericType(ti.tp) || ti.tp.IsGenericType || !ti.tp.IsEnum))
|
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))
|
if (!(ti.tp is EnumBuilder))
|
||||||
il.Emit(OpCodes.Ldelema, ti.tp);
|
il.Emit(OpCodes.Ldelema, ti.tp);
|
||||||
|
if (_arr_type.is_nullable_type && exprs[i] is INullConstantNode)
|
||||||
|
{
|
||||||
|
il.Emit(OpCodes.Initobj, helper.GetTypeReference(_arr_type).tp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.il = il;
|
this.il = il;
|
||||||
exprs[i].visit(this);
|
exprs[i].visit(this);
|
||||||
bool box = EmitBox(exprs[i], arr_type.GetElementType());
|
bool box = EmitBox(exprs[i], arr_type.GetElementType());
|
||||||
|
|
@ -4603,12 +4607,14 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
{
|
{
|
||||||
if (!(ti.tp is EnumBuilder))
|
if (!(ti.tp is EnumBuilder))
|
||||||
il.Emit(OpCodes.Ldelema, ti.tp);
|
il.Emit(OpCodes.Ldelema, ti.tp);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (ti != null && ti.assign_meth != null && lb.LocalType.GetElementType() != TypeFactory.ObjectType)
|
if (ti != null && ti.assign_meth != null && lb.LocalType.GetElementType() != TypeFactory.ObjectType)
|
||||||
il.Emit(OpCodes.Ldelem_Ref);
|
il.Emit(OpCodes.Ldelem_Ref);
|
||||||
|
|
||||||
this.il = il;
|
this.il = il;
|
||||||
|
|
||||||
ElementValues[i].visit(this);
|
ElementValues[i].visit(this);
|
||||||
if (ti != null && ti.assign_meth != null && lb.LocalType.GetElementType() != TypeFactory.ObjectType)
|
if (ti != null && ti.assign_meth != null && lb.LocalType.GetElementType() != TypeFactory.ObjectType)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
4
TestSuite/nullable15.pas
Normal file
4
TestSuite/nullable15.pas
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
begin
|
||||||
|
var a := new System.Nullable<integer>[](nil);
|
||||||
|
assert(a[0] = nil);
|
||||||
|
end.
|
||||||
4
TestSuite/nullable16.pas
Normal file
4
TestSuite/nullable16.pas
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
var a := new System.Nullable<integer>[](nil);
|
||||||
|
begin
|
||||||
|
assert(a[0] = nil);
|
||||||
|
end.
|
||||||
8
TestSuite/nullable17.pas
Normal file
8
TestSuite/nullable17.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
procedure test(params a: array of System.Nullable<integer>);
|
||||||
|
begin
|
||||||
|
assert(a[0] = nil);
|
||||||
|
assert(a[1] = 1);
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
test(nil, 1);
|
||||||
|
end.
|
||||||
Loading…
Reference in a new issue