Lambda with statement not block doesn't compile

Both the following function definitions compile fine:

proc f(n: int): int { return 1; }
proc f(n: int): int return 1;

The following lambda using a block works fine:

var f = lambda (n: int): int { return 1; };

but using just a statement causes a compilation fail:

var f = lambda (n: int): int return 1;

is this as it should be or is it something that should be fixed?

It’s not clear to me in the spec whether or not this should work. I think we need to either add support for this syntax or clear up the ambiguity in the spec. In either case, I think this would be better suited as a github issue to track this until it is addressed.

1 Like

Do you want me to transfer the item to the issues or is this something you will do? (Best to make sure someone does it :slight_smile: )

Done here: https://github.com/chapel-lang/chapel/issues/16604

Feel free to make these types of topics GitHub issues to begin with. If it turns out to be a non-issue or user error, we can close it and it will stay in the issue archives for others to search against if they run into the same user error.

1 Like