cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] Can not declare functions that return function pointers

Open Xeverous opened this issue 7 months ago • 2 comments

Describe the bug I copy pasted an example from wiki (https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-operators) to play with and it does not parse.

To Reproduce Sample code:

f: (i: int) -> * (j: int) -> string = { return nullptr; }

Result:

main.cpp2...
main.cpp2(1,25): error: missing ';' at end of declaration or '=' at start of initializer (at '->')
main.cpp2(1,1): error: unexpected text at end of Cpp2 code section (at 'f')
main.cpp2(1,0): error: parse failed for section starting here

Steps to reproduce the behavior: Run as ./source/cppfront main.cpp2 -p with cppfront built from commit 5aa32aef7c74679994d6da39e6d0cf9b9714e1ee.

Additional context Would be nice if it got fixed with a unit test for something like this:

// C stdlib and POSIX function
void (*signal(int signum, void (*handler)(int)))(int)
// expected C++2 syntax
signal: (signum: int, handler: *(_: int) -> void) -> *(_: int) -> void

Xeverous avatar May 30 '25 13:05 Xeverous