@@ -1063,7 +1063,7 @@ struct declaration_node
1063
1063
source_position pos;
1064
1064
std::unique_ptr<unqualified_id_node> identifier;
1065
1065
1066
- enum active : std::uint8_t { function, object };
1066
+ enum active : std::uint8_t { function, object, udt_type };
1067
1067
std::variant<
1068
1068
std::unique_ptr<function_type_node>,
1069
1069
std::unique_ptr<type_id_node>
@@ -1563,7 +1563,7 @@ class parser
1563
1563
}
1564
1564
1565
1565
if (curr ().type () == lexeme::LeftParen
1566
- // If in the future (not now) we want to experiment with braced-expressions
1566
+ // If in the future (not now) we decide to allow braced-expressions
1567
1567
// || curr().type() == lexeme::LeftBrace
1568
1568
)
1569
1569
{
@@ -1589,25 +1589,25 @@ class parser
1589
1589
return n;
1590
1590
}
1591
1591
1592
- if (auto decl = unnamed_declaration (curr ().position (), true , true )) // captures are allowed
1592
+ if (auto decl = unnamed_declaration (curr ().position (), false , true )) // captures are allowed
1593
1593
{
1594
1594
assert (!decl->identifier && " ICE: declaration should have been unnamed" );
1595
- if (! decl->is (declaration_node::function )) {
1596
- error (" an unnamed declaration at expression scope must be a function" );
1595
+ if (decl->is (declaration_node::udt_type )) {
1596
+ error (" (temporary alpha limitation) an unnamed declaration at expression scope must be a function or an object " );
1597
1597
next ();
1598
1598
return {};
1599
1599
}
1600
- auto & func = std::get <declaration_node::function>(decl->type );
1601
- assert ( func);
1602
- if (func-> returns . index () == function_type_node::list) {
1603
- error ( " an unnamed function at expression scope currently cannot return multiple values " );
1604
- next () ;
1605
- return {};
1606
- }
1607
- if (!func-> contracts . empty ()) {
1608
- error ( " an unnamed function at expression scope currently cannot have contracts " );
1609
- next () ;
1610
- return {};
1600
+ if ( auto func = std::get_if <declaration_node::function>(& decl->type )) {
1601
+ if ((* func)-> returns . index () == function_type_node::list) {
1602
+ error ( " an unnamed function at expression scope currently cannot return multiple values " );
1603
+ next ( );
1604
+ return {} ;
1605
+ }
1606
+ if (!(*func)-> contracts . empty ()) {
1607
+ error ( " an unnamed function at expression scope currently cannot have contracts" );
1608
+ next ( );
1609
+ return {} ;
1610
+ }
1611
1611
}
1612
1612
1613
1613
n->expr = std::move (decl);
0 commit comments