Oxygene Tuple: Untyped null values not allowed, in IF THEN expression?

@mh
I have the following IF THEN EXPRESSION code that gives me error E698: Untyped null values not allowed in tuple

method GetOperationByName(const aName: not nullable String): Tuple of (Boolean, Operation);
begin      
  var opPtr := TF_GraphOperationByName(ObjectPtr, aName.ToAnsiChars(true));
  result := if assigned(opPtr) then
              (true, new Operation withObjectPtr(opPtr) Name(aName))
            else
              (false, nil);
end;

However, it compiles fine, for the following code that uses normal IF THEN statements:

method GetOperationByName(const aName: not nullable String): Tuple of (Boolean, Operation);
begin      
  var opPtr := TF_GraphOperationByName(ObjectPtr, aName.ToAnsiChars(true));
  if assigned(opPtr) then 
    result := (true, new Operation withObjectPtr(opPtr) Name(aName))
  else
    result := (false, nil);
end;

Is this expected?

Yeah, that’s a limitation of type inference for if expressions.

It works if you do Operation(nil). The reason for this is that if and case expressions need to be able to infer the type of an expression. And nil has no type. The compiler is unable to find common ground in this expression, which is required for IF to have a result type.