Skip to content

Commit c74208f

Browse files
committed
fix(parse): permit unbraced function expression as template argument
1 parent 96cf605 commit c74208f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

regression-tests/test-results/pure2-bugfix-for-unbraced-function-expression.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11

2-
#define CPP2_USE_MODULES Yes
2+
#define CPP2_IMPORT_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

66

77
#include "cpp2util.h"
88

9-
#line 1 "pure2-bugfix-for-unbraced-function-expression.cpp2"
109
class t;
1110

1211

1312
//=== Cpp2 type definitions and function declarations ===========================
1413

15-
#line 1 "pure2-bugfix-for-unbraced-function-expression.cpp2"
1614
class t {
17-
public: auto operator[](auto const& f) const -> void;
15+
public: auto operator[](auto const& f) const& -> void;
1816

1917
public: t() = default;
2018
public: t(t const&) = delete; /* No 'that' constructor, suppress copy */
@@ -28,7 +26,7 @@ class t {
2826

2927

3028
#line 2 "pure2-bugfix-for-unbraced-function-expression.cpp2"
31-
auto t::operator[](auto const& f) const -> void{}
29+
auto t::operator[](auto const& f) const& -> void{}
3230

3331
[[nodiscard]] auto main() -> int{
3432
{

source/parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,6 +5364,7 @@ class parser
53645364
&& curr().type() != lexeme::LeftParen // not imediatelly called
53655365
&& curr().type() != lexeme::RightParen // not as a last argument to function
53665366
&& curr().type() != lexeme::Comma // not as first or in-the-middle, function argument
5367+
&& curr().type() != lexeme::Greater // not as the last argument to template
53675368
&& curr().type() != lexeme::RightBracket // not as the last index argument
53685369
&& curr() != "is" // not as the argument to is
53695370
&& curr() != "as" // not as the argument to as

0 commit comments

Comments
 (0)