Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
u: type == std::array<i32, 2>;
t: @struct type = {
this: std::integral_constant<u, :u = (17, 29)>;
}
main: () = {
[[assert Testing: t::value[0] == 17]]
[[assert Testing: t::value[1] == 29]]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#define CPP2_USE_MODULES Yes

//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"


#line 2 "pure2-bugfix-for-non-local-initialization.cpp2"
class t;


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

#line 1 "pure2-bugfix-for-non-local-initialization.cpp2"
using u = std::array<cpp2::i32,2>;
class t: public std::integral_constant<u,u{17, 29}> {

};
auto main() -> int;


//=== Cpp2 function definitions =================================================


#line 5 "pure2-bugfix-for-non-local-initialization.cpp2"
auto main() -> int{
cpp2::Testing.expects(cpp2::assert_in_bounds(t::value, 0)==17, "");
cpp2::Testing.expects(cpp2::assert_in_bounds(t::value, 1)==29, "");
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pure2-bugfix-for-non-local-initialization.cpp2... ok (all Cpp2, passes safety checks)

9 changes: 5 additions & 4 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -4161,6 +4161,7 @@ class parser
curr().type() != lexeme::Semicolon
&& curr().type() != lexeme::RightParen
&& curr().type() != lexeme::RightBracket
&& curr().type() != lexeme::Greater
&& curr().type() != lexeme::Comma
) {
expr_list->inside_initializer = false;
Expand Down Expand Up @@ -5031,20 +5032,20 @@ class parser
}
return expression(false); // false == disallow unparenthesized relational comparisons in template args
}()
)
)
{
term.arg = std::move(e);
}

// Else try parsing it as a type id
else if (auto i = type_id()) {
term.arg = std::move(i);
}

else {
break;
}

n->template_args.push_back( std::move(term) );
}
// Use the lambda trick to jam in a "next" clause
Expand Down