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
auto func1() -> void { std::cout << "HI" << "\n"; }
auto func2() -> void { return; }
But it generates the following C++ code:
auto func1() -> void { std::cout << "HI" << "\n"; }
auto func2() -> voidreturn ;
Additional context
The transpiler is combined the return type void and the statement return of func2, becuase it missed block symbols {} in the generated code.
The text was updated successfully, but these errors were encountered:
This is an omnibus commit of the last few evenings' changes. Primarily it was to start laying the groundwork for constructors, but it includes other fixes and closes a few issues.
Details:
- Begin infrastructure preparation for constructors
- Started creating navigation APIs to replace the low-level graph node chasing; this makes cppfront's own code cleaner and the tree easier to change if needed, but it's also a step toward a reflection API
- Extended `main:(args)` to require the name "args" for the single-parameter `main`, and to support `args.argc` and `args.argv`, further on hsutter#262 (see comment thread)
- Changed default return type for unnamed functions to be `-> void`, same as named functions, closeshsutter#257
- Disallow single-expression function body to be just `return`, closeshsutter#267
- Make `make_args` inline, closeshsutter#268
- Bug fix: emit prolog also for single-expression function body. Specifically, this enables main:(args)=expression; to work correctly. Generally, this also corrects the code gen for examples that were trying (but failing) to inject prologs in single-expression functions... in the regression tests this corrected the code gen for `pure2-forward-return.cpp2` which was missing the contract check before.
Describe the bug
A
return
statement inside the one-line style function definition, generates bad code.To Reproduce
This is the sample CPP2 code:
I've used Compiler Explorer.
It should generate the following C++ code:
But it generates the following C++ code:
Additional context
The transpiler is combined the return type
void
and the statementreturn
offunc2
, becuase it missed block symbols{}
in the generated code.The text was updated successfully, but these errors were encountered: