Skip to content

Commit

Permalink
Allow boolean negation in guard clauses
Browse files Browse the repository at this point in the history
This is newly allowed in v0.33.0.
  • Loading branch information
the-mikedavis committed Dec 6, 2023
1 parent 78123c1 commit fa28819
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ module.exports = grammar({
_case_clause_guard_expression: ($) =>
choice(
$._case_clause_guard_unit,
alias($._case_clause_guard_binary_expression, $.binary_expression)
alias($._case_clause_guard_binary_expression, $.binary_expression),
$.boolean_negation
),
_case_clause_guard_binary_expression: ($) =>
choice(
Expand Down
32 changes: 32 additions & 0 deletions test/corpus/cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,35 @@ case tag {
(argument
(record
(constructor_name)))))))))

================================================================================
Case with boolean negation in a guard
================================================================================

case var {
1 if !other_var -> True
_ -> False
}

--------------------------------------------------------------------------------

(source_file
(case
(case_subjects
(identifier))
(case_clauses
(case_clause
(case_clause_patterns
(case_clause_pattern
(integer)))
(case_clause_guard
(boolean_negation
(identifier)))
(record
(constructor_name)))
(case_clause
(case_clause_patterns
(case_clause_pattern
(discard)))
(record
(constructor_name))))))

0 comments on commit fa28819

Please sign in to comment.