Skip to content

Commit fa9ba7f

Browse files
committed
Require template argument list to not be preceded by whitespace
This is a better solution for #695 Now `S: @struct <T> type` just works and does the expected thing
1 parent 673e232 commit fa9ba7f

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8928:1101
2+
cppfront compiler v0.2.1 Build 8928:1119
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8928:1101"
1+
"8928:1119"

source/parse.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6128,10 +6128,15 @@ class parser
61286128
auto n = std::make_unique<unqualified_id_node>();
61296129

61306130
n->identifier = &curr();
6131+
auto one_past_identifier_end_pos = curr().position();
6132+
one_past_identifier_end_pos.colno += curr().length();
61316133
next();
61326134

61336135
// Handle the template-argument-list if there is one
6134-
if (curr().type() == lexeme::Less)
6136+
if (
6137+
curr().type() == lexeme::Less
6138+
&& curr().position() == one_past_identifier_end_pos
6139+
)
61356140
{
61366141
// Remember current position, in case this < is isn't a template argument list
61376142
auto start_pos = pos;

source/reflect.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,6 @@ auto print(cpp2::in<meta::type_declaration> t) -> void;
718718
namespace cpp2 {
719719

720720

721-
//-----------------------------------------------------------------------
722-
//
723-
// Now finish the rest of the parser definition
724-
//
725-
//-----------------------------------------------------------------------
726-
//
727-
728721
auto parser::apply_type_metafunctions( declaration_node& n )
729722
-> bool
730723
{
@@ -1774,7 +1767,7 @@ auto print(cpp2::in<meta::type_declaration> t) -> void
17741767
&& !(CPP2_UFCS_0(arguments_were_used, rtype))))
17751768

17761769
{
1777-
error(name + " did not use its template arguments - did you mean to write '" + name + "<" + cpp2::assert_in_bounds(args, 0) + ": type>' ?");
1770+
error(name + " did not use its template arguments - did you mean to write '" + name + " <" + cpp2::assert_in_bounds(args, 0) + "> type' (with the spaces)?");
17781771
return false;
17791772
}
17801773
}

source/reflect.h2

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ apply_metafunctions: (
12711271
&& !rtype.arguments_were_used()
12721272
)
12731273
{
1274-
error( name + " did not use its template arguments - did you mean to write '" + name + "<" + args[0] + ": type>' ?");
1274+
error( name + " did not use its template arguments - did you mean to write '" + name + " <" + args[0] + "> type' (with the spaces)?");
12751275
return false;
12761276
}
12771277
}
@@ -1287,13 +1287,6 @@ apply_metafunctions: (
12871287
namespace cpp2 {
12881288

12891289

1290-
//-----------------------------------------------------------------------
1291-
//
1292-
// Now finish the rest of the parser definition
1293-
//
1294-
//-----------------------------------------------------------------------
1295-
//
1296-
12971290
auto parser::apply_type_metafunctions( declaration_node& n )
12981291
-> bool
12991292
{

0 commit comments

Comments
 (0)