Skip to content
Next Next commit
Add support for applying metafunctions to functions
Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
  • Loading branch information
DyXel and JohelEGP committed Aug 24, 2024
commit 39c11dbc0a70750b6c7d1ad6154cb0293fab5df5
22 changes: 14 additions & 8 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -8544,6 +8544,9 @@ class parser
auto apply_type_metafunctions( declaration_node& decl )
-> bool;

auto apply_function_metafunctions( declaration_node& decl )
-> bool;


//G unnamed-declaration:
//G ':' meta-functions? template-parameters? function-type requires-clause? '=' statement
Expand Down Expand Up @@ -8753,14 +8756,6 @@ class parser
{
n->type = std::move(t);
assert (n->is_function());

if (!n->metafunctions.empty()) {
errors.emplace_back(
n->metafunctions.front()->position(),
"(temporary alpha limitation) metafunctions are currently not supported on functions, only on types"
);
return {};
}
}

// Or a namespace
Expand Down Expand Up @@ -9123,6 +9118,17 @@ class parser
);
}

// If this is a function with metafunctions, apply those
if (n->is_function()) {
if (!apply_function_metafunctions(*n)) {
error(
"error encountered while applying function metafunctions",
false, {}, true
);
return {};
}
}

return n;
}

Expand Down
Loading