File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -10483,16 +10483,22 @@ Parser<ManagedTokenSource>::parse_pattern ()
1048310483 return first;
1048410484
1048510485 std::vector<std::unique_ptr<AST::Pattern>> alts;
10486- alts.push_back (std::move (first));
10486+ if (first != nullptr )
10487+ alts.push_back (std::move (first));
1048710488
1048810489 do
1048910490 {
1049010491 lexer.skip_token ();
10491- alts.push_back (parse_pattern_no_alt ());
10492+ auto follow = parse_pattern_no_alt ();
10493+ if (follow != nullptr )
10494+ alts.push_back (std::move (follow));
1049210495 }
1049310496
1049410497 while (lexer.peek_token ()->get_id () == PIPE);
1049510498
10499+ if (alts.empty ())
10500+ return nullptr ;
10501+
1049610502 /* alternates */
1049710503 return std::unique_ptr<AST::Pattern> (
1049810504 new AST::AltPattern (std::move (alts), start_locus));
Original file line number Diff line number Diff line change 1+ struct Bug {
2+ inner : [ ( ) ; match Vec :: new {
3+ f @ |n( ) => 1
4+ // { dg-error "failed to parse pattern to bind" "" { target *-*-* } .-1 }
5+ // { dg-error "unexpected token .|. in pattern" "" { target *-*-* } .-2 }
6+ } ] ,
7+ }
You can’t perform that action at this time.
0 commit comments