Skip to content

Commit

Permalink
Require namespace-scope objects to have a concrete type, closes hsutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter authored and zaucy committed Dec 5, 2023
1 parent 885392e commit 47d9ebd
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ struct declaration_node
;
}

auto is_wildcard() const
auto has_wildcard_type() const
-> bool
{
return
Expand Down Expand Up @@ -5488,6 +5488,14 @@ class parser
// First see if it's an alias declaration
n = alias();
if (n) {
if (is_parameter) {
errors.emplace_back(
curr().position(),
"a parameter declaration may not be an alias declaration"
);
return {};
}

n->pos = start_pos;
n->identifier = std::move(id);
n->access = access;
Expand All @@ -5513,6 +5521,20 @@ class parser

// Note: Do this after trying to parse this as a declaration, for parse backtracking

if (
!is_parameter
&& n->is_object()
&& n->has_wildcard_type()
&& n->parent_is_namespace()
)
{
errors.emplace_back(
n->identifier->position(),
"namespace scope objects must have a concrete type, not a deduced type"
);
return {};
}

if (
n->has_name("_")
&& !n->is_object()
Expand Down

0 comments on commit 47d9ebd

Please sign in to comment.