cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] using N:namespace = ... suppress creation of struct for multiple return values

Open filipsajdak opened this issue 3 years ago • 0 comments
trafficstars

I know that namespaces are not supported yet by cppfront. Unfortunately, it can be added following the l-to-r approach, it compiles by cppfront but fails to compile by cpp1 compiler.

N: namespace = fun: () -> (a:int) = {
    a = 42;
    return;
}

Cppfront compiles fine but generates code that will not compile as it doesn't have a struct definition for multiple return values.

// ----- Cpp2 support -----
#include "cpp2util.h"



//=== Cpp2 definitions ==========================================================

   namespace N { [[nodiscard]] auto fun() -> fun__ret{
                       cpp2::deferred_init<int> a;
    a.construct(42);
    return  { std::move(a.value()) }; 
} }; 

https://godbolt.org/z/vr51TExGG

No definition of fun__ret.

Expected behavior: cppfront forbids namespaces/struct/class to be used like that or generates correct code.

filipsajdak avatar Oct 09 '22 19:10 filipsajdak