cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

fix(to_cpp1): define type-scope object alias with wildcard type inline

Open JohelEGP opened this issue 2 years ago • 4 comments
trafficstars

Resolves #700. Resolves #842. Resolves #1221.

JohelEGP avatar Sep 26 '23 16:09 JohelEGP

evens_doubled: @struct type = {
  filter :== :(x: int) x % 2 == 0;
  map    :== :(x: int) x * 2;
}

currently emits to

/home/johel/tmp/Waarudo/ClangDebug/sources/main.cpp:23:42: error: expected expression
   23 |   public: static constexpr auto filter = public: [](cpp2::in<int> x) -> auto { return x % 2 == 0; };
      |                                          ^
/home/johel/tmp/Waarudo/ClangDebug/sources/main.cpp:23:33: error: declaration of variable 'filter' with deduced type 'const auto' requires an initializer
   23 |   public: static constexpr auto filter = public: [](cpp2::in<int> x) -> auto { return x % 2 == 0; };
      |                                 ^
/home/johel/tmp/Waarudo/ClangDebug/sources/main.cpp:24:39: error: expected expression
   24 |   public: static constexpr auto map = public: [](cpp2::in<int> x) -> auto { return x * 2; };
      |                                       ^
/home/johel/tmp/Waarudo/ClangDebug/sources/main.cpp:24:33: error: declaration of variable 'map' with deduced type 'const auto' requires an initializer
   24 |   public: static constexpr auto map = public: [](cpp2::in<int> x) -> auto { return x * 2; };
      |                                 ^
4 errors generated.

JohelEGP avatar Nov 17 '23 19:11 JohelEGP