cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] cppfront >v0.8 emit uncompilable C++ code

Open akornilov opened this issue 4 months ago • 1 comments

Describe the bug The simple hello example successfully processed by cppfront v0.7.3, but cppfront >v0.8.x emit uncompilable C++ code

To Reproduce Steps to reproduce the behavior:

  1. `main: () = { words: std::vector = ( "Alice", "Bob" ); hello( words[0] ); hello( words[1] ); }

hello: (msg: std::string_view) = std::cout << "Hello, (msg)$!\n";`

  1. Command lines including which C++ compiler you are using: cppfront hello.cpp2
  2. Expected result - what you expected to happen: cppfront v0.7.3 generate: auto hello(cpp2::impl::in<std::string_view> msg) -> void;
  3. Actual result/error cppfront v0.8.x generate: [[nodiscard]] auto hello(cpp2::impl::in<std::string_view> msg) -> decltype(auto);

gcc error: error: use of ‘decltype(auto) hello(cpp2::impl::in<std::basic_string_view >)’ before deduction of ‘auto’ msvc error: error C3779: 'hello': a function that returns 'decltype(auto)' cannot be used before it is defined

Additional context Issue can be simply fixed in cpp2 code like this: hello: (msg: std::string_view) = { std::cout << "Hello, (msg)$!\n"; } But this is very strange in my opinion.

akornilov avatar Sep 09 '25 18:09 akornilov