Skip to content

Commit

Permalink
Accept single semicolon switch blocks in FFP
Browse files Browse the repository at this point in the history
Summary:
Accept statements of type
```
$v = 1;
switch($v) {
    ;
}
```
Required for PHP parity

Differential Revision: D6909127

fbshipit-source-id: f71374cfd8bb6f39789612ca7dae930ce51c6489
  • Loading branch information
vassilmladenov authored and hhvm-bot committed Feb 15, 2018
1 parent 66c241d commit 2627ff1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hphp/hack/src/parser/full_fidelity_statement_parser.ml
Expand Up @@ -599,7 +599,13 @@ module WithExpressionAndDeclAndTypeParser
(* TODO: I'm not convinced that this always terminates in some cases.
Check that. *)
let (parser, section_list) =
parse_terminated_list parser parse_switch_section RightBrace in
let (parser1, token) = next_token parser in
match Token.kind token with
| Semicolon when peek_token_kind parser1 = RightBrace ->
parser1, make_list parser1 []
| _ ->
parse_terminated_list parser parse_switch_section RightBrace
in
let (parser, right_brace_token) = require_right_brace parser in
let syntax = make_switch_statement switch_keyword_token left_paren_token
expr_node right_paren_token left_brace_token section_list
Expand Down

0 comments on commit 2627ff1

Please sign in to comment.