Skip to content

Commit cd961d1

Browse files
committed
Require namespace-scope objects to have a concrete type, closes #315
1 parent f608b78 commit cd961d1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

source/parse.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ struct declaration_node
19341934
;
19351935
}
19361936

1937-
auto is_wildcard() const
1937+
auto has_wildcard_type() const
19381938
-> bool
19391939
{
19401940
return
@@ -5488,6 +5488,14 @@ class parser
54885488
// First see if it's an alias declaration
54895489
n = alias();
54905490
if (n) {
5491+
if (is_parameter) {
5492+
errors.emplace_back(
5493+
curr().position(),
5494+
"a parameter declaration may not be an alias declaration"
5495+
);
5496+
return {};
5497+
}
5498+
54915499
n->pos = start_pos;
54925500
n->identifier = std::move(id);
54935501
n->access = access;
@@ -5513,6 +5521,20 @@ class parser
55135521

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

5524+
if (
5525+
!is_parameter
5526+
&& n->is_object()
5527+
&& n->has_wildcard_type()
5528+
&& n->parent_is_namespace()
5529+
)
5530+
{
5531+
errors.emplace_back(
5532+
n->identifier->position(),
5533+
"namespace scope objects must have a concrete type, not a deduced type"
5534+
);
5535+
return {};
5536+
}
5537+
55165538
if (
55175539
n->has_name("_")
55185540
&& !n->is_object()

0 commit comments

Comments
 (0)