Skip to content

[BUG] Bad code is generated for return inside the one-line style function definition #267

Closed
@msadeqhe

Description

@msadeqhe

Describe the bug
A return statement inside the one-line style function definition, generates bad code.

To Reproduce
This is the sample CPP2 code:

#include <iostream>

func1 :() = std::cout << "HI" << "\n";
func2 :() = return;

I've used Compiler Explorer.

It should generate the following C++ code:

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions