Skip to content

[BUG] Can not declare functions that return function pointers #1397

Open
@Xeverous

Description

@Xeverous

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 5aa32ae.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions