Lambda and throws

The function:

proc iterative_f(n:int): bigint throws return iterative(n);

compiles fine and does what is expected of it. In particular:

const functions = (iterative_f,);

does as expected.

However,

const functions = (
  lambda (n:int): bigint throws { return iterative(n); },
);

fails with:

test/Factorial_Chapel_Test.chpl:24: syntax error: near 'throws'

Removing the throws from the lambda allows for compilation but the exception is not propagated as required for the tests to work.

Hi @Russel, this looks like a bug in throwing lambdas.

Would you mind filing a new GitHub issue for this?

Here’s a slightly simpler reproducer:

var f = lambda (n:int): int throws { return 1; }; // works without throws

Issue raised https://github.com/chapel-lang/chapel/issues/16580

1 Like