diff --git a/compiler/src/formatting/format.re b/compiler/src/formatting/format.re index e2469f2319..519736cd82 100644 --- a/compiler/src/formatting/format.re +++ b/compiler/src/formatting/format.re @@ -51,6 +51,7 @@ let is_logic_op = fn => | "==" | "!=" | "is" + | "isnt" | "&&" | "||" => true | _ => false @@ -104,7 +105,8 @@ let op_precedence = fn => { | "!=" | "is" => 80 | "&&" => 40 - | "||" => 30 + | "||" + | "??" => 30 | _ => op_precedence(fn.[0]) }; } else if (String.length(fn) > 0) { @@ -287,10 +289,11 @@ let infixop = (op: string) => { | '<' | '>' | '&' - | '|' => true + | '|' + | '?' => true | _ when op == "is" => true | _ when op == "isnt" => true - | _ when op == "!=" => true + | _ when String.starts_with(~prefix="!=", op) => true | _ => false | exception _ => false }; diff --git a/compiler/test/formatter_inputs/infix.gr b/compiler/test/formatter_inputs/infix.gr index b90cdd5bd9..a6bf4a6303 100644 --- a/compiler/test/formatter_inputs/infix.gr +++ b/compiler/test/formatter_inputs/infix.gr @@ -21,3 +21,43 @@ let trimString = (str: String, end: Bool) => { else slice(i, charsLength, str) } +(||+) +(||^) +(&&*&^%) +(|*) +(^^^) +(&-) +(==!) +(==$) +(==*==) +(!==^) +(<<<<<) +(<%>) +(<=>) +(>>>>) +(>>>>>>>>) +(><><><) +(+==) +(+!) +(++!) +(+-+) +(**//**) +(**) +(??) +(???) +(+.) +(-.) +(*.) +(/.) +(>>=) +(|>) +(>:) +(%%) +(===) +(!==) +(==?) +(&?) +(++) +(--) +(^*^) +(^-^) diff --git a/compiler/test/formatter_outputs/infix.gr b/compiler/test/formatter_outputs/infix.gr index 3b83b6239a..355279064a 100644 --- a/compiler/test/formatter_outputs/infix.gr +++ b/compiler/test/formatter_outputs/infix.gr @@ -19,3 +19,44 @@ let trimString = (str: String, end: Bool) => { } if (end) slice(0, i + 1, str) else slice(i, charsLength, str) } + +(||+) +(||^) +(&&*&^%) +(|*) +(^^^) +(&-) +(==!) +(==$) +(==*==) +(!==^) +(<<<<<) +(<%>) +(<=>) +(>>>>) +(>>>>>>>>) +(><><><) +(+==) +(+!) +(++!) +(+-+) +(**//**) +(**) +(??) +(???) +(+.) +(-.) +(*.) +(/.) +(>>=) +(|>) +(>:) +(%%) +(===) +(!==) +(==?) +(&?) +(++) +(--) +(^*^) +(^-^)