This commit is contained in:
parent
4e208d36a7
commit
148dac36c4
|
|
@ -11046,7 +11046,10 @@ namespace PascalABCCompiler.NETGenerator
|
|||
is_dot_expr = tmp_is_dot_expr;
|
||||
is_addr = tmp_is_addr;
|
||||
il.Emit(OpCodes.Brtrue, NullLabel);
|
||||
il.Emit(OpCodes.Ldloc, tmp_lb);
|
||||
if (value.condition.type.is_nullable_type)
|
||||
il.Emit(OpCodes.Ldloca, tmp_lb);
|
||||
else
|
||||
il.Emit(OpCodes.Ldloc, tmp_lb);
|
||||
TypeInfo ti = helper.GetTypeReference(value.condition.type);
|
||||
if (ti != null)
|
||||
EmitBox(value.condition, ti.tp);
|
||||
|
|
|
|||
13
TestSuite/nullable14.pas
Normal file
13
TestSuite/nullable14.pas
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function f1 := 1;
|
||||
|
||||
function p1(n: integer?): integer;
|
||||
begin
|
||||
Result := (n??f1).Value;
|
||||
end;
|
||||
|
||||
begin
|
||||
// OK
|
||||
assert(p1(nil) = 1);
|
||||
// AccessViolationException
|
||||
assert(p1(5) = 5);
|
||||
end.
|
||||
Loading…
Reference in a new issue