You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Can not declare functions that return function pointers #1397
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:
My guess is that the compiler is getting confused by multiple -> operators, but that's just a guess for right now. (And it gets even more confused if you put *(_: int) -> void into parentheses.)
Activity
threeifbyair commentedon Jun 21, 2025
I took a look at this and reproduced your problem. I'll dig a little deeper, but in the meantime, here is a workaround:
intfuncptr: type == *(_: int) -> void;
signal: (signum: int, handler: intfuncptr) -> intfuncptr
My guess is that the compiler is getting confused by multiple -> operators, but that's just a guess for right now. (And it gets even more confused if you put *(_: int) -> void into parentheses.)
threeifbyair commentedon Jun 21, 2025
In case I don't come back to this, we have three different cases:
The first fails to parse. The second complains that the _ argument in the return value has not been initialized (?!). The third works fine.