Skip to content

Commit e4be436

Browse files
committed
feat(parse)!: introduce specialization with 'specialize'
1 parent c6da6dc commit e4be436

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

regression-tests/pure2-template-specialization.cpp2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
t: @struct <T: type> type = {
22
a: i32 = 1;
33
}
4-
t: @struct <T: type> type < T> type requires std::is_void_v < T> = {
4+
t: @struct <T: type> specialize<T> type requires std::is_void_v<T> = {
55
b: i32 = 2;
66
}
7-
t: @struct type < i64> type = {
7+
t: @struct specialize<i64> type = {
88
c: i32 = 3;
99
}
10-
v: <T> i32 = 1; // clang-format off
11-
v: <> type<void> i32 = 2; // clang-format on
10+
v: <T> i32 = 1;
11+
v: <> specialize<void> i32 = 2;
1212
main: () = {
1313
[[assert Testing: t<i32>().a == 1]]
1414
[[assert Testing: t<void>().b == 2]]

regression-tests/test-results/pure2-template-specialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ template<typename T> requires( std::is_void_v<T> )
2222
template<> class t<cpp2::i64> {
2323
public: cpp2::i32 c {3};
2424
};
25-
template<typename T> extern cpp2::i32 v;// clang-format off
26-
// clang-format on
25+
template<typename T> extern cpp2::i32 v;
26+
2727
auto main() -> int;
2828

2929

source/parse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6473,7 +6473,7 @@ class parser
64736473
//G '<' parameter-declaration-seq? '>'
64746474
//G
64756475
//G template-specialization-argument-list:
6476-
//G 'type' '<' template-argument-list '>'
6476+
//G 'specialize' '<' template-argument-list '>'
64776477
//G
64786478
auto unnamed_declaration(
64796479
source_position start,
@@ -6612,7 +6612,7 @@ class parser
66126612

66136613
// Next is an optional template specialization argument list
66146614
if (
6615-
curr() == "type"
6615+
curr() == "specialize"
66166616
&& peek(1)
66176617
&& peek(1)->type() == lexeme::Less
66186618
)

0 commit comments

Comments
 (0)