RATools icon indicating copy to clipboard operation
RATools copied to clipboard

Cannot use anonymous predicate as default function argument ("Default value for pred is not constant")

Open Souzooka opened this issue 10 months ago • 0 comments

The following code:

function foo(pred=(v) => v)
{
  return always_true()
}

will create the error Default value for pred is not constant.

However, the following code:

_ = v => v
function foo(pred=_)
{
  return always_true()
}

will compile without error.

This issue seems to suggest that any anonymous predicates cannot be used as default function arguments, whereas there's no technical reason why that shouldn't be the case.

Souzooka avatar Mar 31 '24 14:03 Souzooka