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
5 changes: 1 addition & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,7 @@ module.exports = grammar({

try_expression: $ => seq(
'try',
choice(
$.block,
$.primary_expression,
),
$.expression,
'catch',
'{',
repeat($.switch_match),
Expand Down
18 changes: 17 additions & 1 deletion test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,12 @@ try switch foo() {
| Js.Exn.Error(obj) => "error"
}

try for i in 0 to 10 {
call()
} catch {
| Not_found => false
}

---

(source_file
Expand Down Expand Up @@ -1320,7 +1326,17 @@ try switch foo() {
(module_identifier))
(variant_identifier))
(formal_parameters (value_identifier)))
(sequence_expression (expression_statement (string (string_fragment))))))))
(sequence_expression (expression_statement (string (string_fragment)))))))

(expression_statement
(try_expression
(for_expression (value_identifier) (number) (number)
(block
(expression_statement
(call_expression (value_identifier) (arguments)))))
(switch_match
(variant_pattern (variant_identifier))
(sequence_expression (expression_statement (false)))))))

===========================================
Mutation expressions
Expand Down