diff --git a/compiler/ml/unified_ops.ml b/compiler/ml/unified_ops.ml index 0eacbb5a65..50d0ed94b4 100644 --- a/compiler/ml/unified_ops.ml +++ b/compiler/ml/unified_ops.ml @@ -208,7 +208,7 @@ let entries = }; }; { - path = builtin "~~"; + path = builtin "~~~"; name = "%bitnot"; form = Unary; specialization = @@ -221,20 +221,20 @@ let entries = }; }; { - path = builtin "&"; - name = "%bitand"; + path = builtin "|||"; + name = "%bitor"; form = Binary; specialization = { - int = Pandint; + int = Porint; bool = None; float = None; - bigint = Some Pandbigint; + bigint = Some Porbigint; string = None; }; }; { - path = builtin "^"; + path = builtin "^^^"; name = "%bitxor"; form = Binary; specialization = @@ -246,6 +246,19 @@ let entries = string = None; }; }; + { + path = builtin "&&&"; + name = "%bitand"; + form = Binary; + specialization = + { + int = Pandint; + bool = None; + float = None; + bigint = Some Pandbigint; + string = None; + }; + }; |] let index_by_path = diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index b9a81d53a9..6774b2bc2b 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -1496,7 +1496,7 @@ and walk_expression expr t comments = { txt = Longident.Lident - ("~+" | "~+." | "~-" | "~-." | "~~" | "not" | "!"); + ("~+" | "~+." | "~-" | "~-." | "~~~" | "not" | "!"); }; }; args = [(Nolabel, arg_expr)]; @@ -1517,7 +1517,8 @@ and walk_expression expr t comments = Longident.Lident ( ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!=" | "!==" | "<=" | ">=" | "+" | "+." | "-" | "-." | "++" - | "^" | "*" | "*." | "/" | "/." | "**" | "->" | "<>" ); + | "|||" | "^^^" | "&&&" | "*" | "*." | "/" | "/." | "**" + | "->" | "<>" ); }; }; args = [(Nolabel, operand1); (Nolabel, operand2)]; diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index 999743ac21..6f212f0e37 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -508,9 +508,12 @@ let make_unary_expr start_pos token_end token operand = } | (Minus | MinusDot), Pexp_constant (Pconst_float (n, m)) -> {operand with pexp_desc = Pexp_constant (Pconst_float (negate_string n, m))} - | (Token.Plus | PlusDot | Minus | MinusDot | Tilde), _ -> + | (Token.Plus | PlusDot | Minus | MinusDot | Bnot), _ -> let token_loc = mk_loc start_pos token_end in - let operator = "~" ^ Token.to_string token in + let token_string = Token.to_string token in + let operator = + if token_string.[0] = '~' then token_string else "~" ^ token_string + in Ast_helper.Exp.apply ~loc:(mk_loc start_pos operand.Parsetree.pexp_loc.loc_end) (Ast_helper.Exp.ident ~loc:token_loc @@ -2292,7 +2295,7 @@ and parse_primary_expr ~operand ?(no_call = false) p = and parse_unary_expr p = let start_pos = p.Parser.start_pos in match p.Parser.token with - | (Minus | MinusDot | Plus | PlusDot | Bang | Tilde) as token -> + | (Minus | MinusDot | Plus | PlusDot | Bang | Bnot) as token -> Parser.leave_breadcrumb p Grammar.ExprUnary; let token_end = p.end_pos in Parser.next p; @@ -5932,7 +5935,7 @@ and parse_polymorphic_variant_type_spec_hash ~attrs ~full p : let ident, loc = parse_hash_ident ~start_pos p in let rec loop p = match p.Parser.token with - | Band when full -> + | Ampersand when full -> Parser.next p; let row_field = parse_polymorphic_variant_type_args p in row_field :: loop p @@ -5940,7 +5943,7 @@ and parse_polymorphic_variant_type_spec_hash ~attrs ~full p : in let first_tuple, tag_contains_a_constant_empty_constructor = match p.Parser.token with - | Band when full -> + | Ampersand when full -> Parser.next p; ([parse_polymorphic_variant_type_args p], true) | Lparen -> ([parse_polymorphic_variant_type_args p], false) diff --git a/compiler/syntax/src/res_grammar.ml b/compiler/syntax/src/res_grammar.ml index 2c5b1e1ac0..8bfbbee590 100644 --- a/compiler/syntax/src/res_grammar.ml +++ b/compiler/syntax/src/res_grammar.ml @@ -151,8 +151,9 @@ let is_atomic_typ_expr_start = function let is_expr_start = function | Token.Assert | At | Await | Backtick | Bang | Codepoint _ | False | Float _ | For | Hash | If | Int _ | Lbrace | Lbracket | LessThan | Lident _ | List - | Lparen | Minus | MinusDot | Module | Percent | Plus | PlusDot | Tilde - | String _ | Switch | True | Try | Uident _ | Underscore (* _ => doThings() *) + | Lparen | Minus | MinusDot | Module | Percent | Plus | PlusDot | Bnot | Bor + | Bxor | Band | String _ | Switch | True | Try | Uident _ + | Underscore (* _ => doThings() *) | While | Forwardslash | ForwardslashDot | Dict -> true | _ -> false diff --git a/compiler/syntax/src/res_parens.ml b/compiler/syntax/src/res_parens.ml index 8c08829461..8d8aeef140 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -129,7 +129,6 @@ let binary_expr_operand ~is_lhs expr = | _ when Ast_uncurried.expr_is_uncurried_fun expr -> Parenthesized | expr when ParsetreeViewer.is_binary_expression expr -> Parenthesized | expr when ParsetreeViewer.is_ternary_expr expr -> Parenthesized - | expr when ParsetreeViewer.is_unary_bitnot_expression expr -> Parenthesized | {pexp_desc = Pexp_assert _} when is_lhs -> Parenthesized | _ when ParsetreeViewer.expr_is_await expr -> Parenthesized | {Parsetree.pexp_attributes = attrs} -> diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index fe5430ebe5..e97c4a03bf 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -267,19 +267,20 @@ let operator_precedence operator = | ":=" -> 1 | "||" -> 2 | "&&" -> 3 - | "^" -> 4 - | "&" -> 5 - | "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" -> 6 - | "<<" | ">>" | ">>>" -> 7 - | "+" | "+." | "-" | "-." | "++" -> 8 - | "*" | "*." | "/" | "/." | "%" -> 9 - | "**" -> 10 - | "#" | "##" | "->" -> 11 + | "|||" -> 4 + | "^^^" -> 5 + | "&&&" -> 6 + | "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" -> 7 + | "<<" | ">>" | ">>>" -> 8 + | "+" | "+." | "-" | "-." | "++" -> 9 + | "*" | "*." | "/" | "/." | "%" -> 10 + | "**" -> 11 + | "#" | "##" | "->" -> 12 | _ -> 0 let is_unary_operator operator = match operator with - | "~+" | "~+." | "~-" | "~-." | "~~" | "not" -> true + | "~+" | "~+." | "~-" | "~-." | "~~~" | "not" -> true | _ -> false let is_unary_expression expr = @@ -293,21 +294,11 @@ let is_unary_expression expr = true | _ -> false -let is_unary_bitnot_expression expr = - match expr.pexp_desc with - | Pexp_apply - { - funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "~~"}}; - args = [(Nolabel, _arg)]; - } -> - true - | _ -> false - let is_binary_operator operator = match operator with | ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!=" | "!==" | "<=" | ">=" | "+" | "+." | "-" | "-." | "++" | "*" | "*." | "/" | "/." | "**" | "->" - | "<>" | "%" | "&" | "^" | "<<" | ">>" | ">>>" -> + | "<>" | "%" | "|||" | "^^^" | "&&&" | "<<" | ">>" | ">>>" -> true | _ -> false diff --git a/compiler/syntax/src/res_parsetree_viewer.mli b/compiler/syntax/src/res_parsetree_viewer.mli index c50e3f2ce8..92108d5018 100644 --- a/compiler/syntax/src/res_parsetree_viewer.mli +++ b/compiler/syntax/src/res_parsetree_viewer.mli @@ -66,7 +66,6 @@ val operator_precedence : string -> int val not_ghost_operator : string -> Location.t -> bool val is_unary_expression : Parsetree.expression -> bool -val is_unary_bitnot_expression : Parsetree.expression -> bool val is_binary_operator : string -> bool val is_binary_expression : Parsetree.expression -> bool val is_rhs_binary_operator : string -> bool diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 2f73bd2684..7132e16dd9 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3777,7 +3777,7 @@ and print_unary_expression ~state expr cmt_tbl = | "~+." -> "+." | "~-" -> "-" | "~-." -> "-." - | "~~" -> "~" + | "~~~" -> "~~~" | "not" -> "!" | _ -> assert false) in @@ -5101,8 +5101,6 @@ and print_argument ~state (arg_lbl, arg) cmt_tbl = match Parens.expr expr with | Parenthesized -> add_parens doc | Braced braces -> print_braces doc expr braces - | Nothing when ParsetreeViewer.is_unary_bitnot_expression expr -> - add_parens doc | Nothing -> doc in let loc = {arg_loc with loc_end = expr.pexp_loc.loc_end} in diff --git a/compiler/syntax/src/res_scanner.ml b/compiler/syntax/src/res_scanner.ml index 7aa249d645..5615b32add 100644 --- a/compiler/syntax/src/res_scanner.ml +++ b/compiler/syntax/src/res_scanner.ml @@ -756,9 +756,14 @@ let rec scan scanner = | '`' -> next scanner; Token.Backtick - | '~' -> - next scanner; - Token.Tilde + | '~' -> ( + match (peek scanner, peek2 scanner) with + | '~', '~' -> + next3 scanner; + Token.Bnot + | _ -> + next scanner; + Token.Tilde) | '?' -> next scanner; Token.Question @@ -830,24 +835,35 @@ let rec scan scanner = next scanner; Token.Percent) | '|' -> ( - match peek scanner with - | '|' -> + match (peek scanner, peek2 scanner) with + | '|', '|' -> + next3 scanner; + Token.Bor + | '|', _ -> next2 scanner; Token.Lor | _ -> next scanner; Token.Bar) | '&' -> ( - match peek scanner with - | '&' -> + match (peek scanner, peek2 scanner) with + | '&', '&' -> + next3 scanner; + Token.Band + | '&', _ -> next2 scanner; Token.Land | _ -> next scanner; - Token.Band) - | '^' -> - next scanner; - Token.Caret + Token.Ampersand) + | '^' -> ( + match (peek scanner, peek2 scanner) with + | '^', '^' -> + next3 scanner; + Token.Bxor + | _ -> + next scanner; + Token.Caret) | ':' -> ( match peek scanner with | '=' -> diff --git a/compiler/syntax/src/res_token.ml b/compiler/syntax/src/res_token.ml index d48a97d24e..ffd85f7f4f 100644 --- a/compiler/syntax/src/res_token.ml +++ b/compiler/syntax/src/res_token.ml @@ -25,6 +25,7 @@ type t = | Equal | EqualEqual | EqualEqualEqual + | Ampersand | Bar | Lparen | Rparen @@ -76,7 +77,10 @@ type t = | Of | Land | Lor - | Band (* Bitwise and: & *) + | Bnot (* Bitwise and: ~~~ *) + | Bor (* Bitwise and: ||| *) + | Bxor (* Bitwise and: ^^^ *) + | Band (* Bitwise and: &&& *) | Caret | BangEqual | BangEqualEqual @@ -104,17 +108,18 @@ let precedence = function | HashEqual | ColonEqual -> 1 | Lor -> 2 | Land -> 3 - | Caret -> 4 - | Band -> 5 + | Bor -> 4 + | Bxor -> 5 + | Band -> 6 | Equal | EqualEqual | EqualEqualEqual | LessThan | GreaterThan | BangEqual | BangEqualEqual | LessEqual | GreaterEqual -> - 6 - | LeftShift | RightShift | RightShiftUnsigned -> 7 - | Plus | PlusDot | Minus | MinusDot | PlusPlus -> 8 - | Asterisk | AsteriskDot | Forwardslash | ForwardslashDot | Percent -> 9 - | Exponentiation -> 10 - | MinusGreater -> 11 - | Dot -> 12 + 7 + | LeftShift | RightShift | RightShiftUnsigned -> 8 + | Plus | PlusDot | Minus | MinusDot | PlusPlus -> 9 + | Asterisk | AsteriskDot | Forwardslash | ForwardslashDot | Percent -> 10 + | Exponentiation -> 11 + | MinusGreater -> 12 + | Dot -> 13 | _ -> 0 let to_string = function @@ -143,6 +148,7 @@ let to_string = function | EqualEqual -> "==" | EqualEqualEqual -> "===" | Eof -> "eof" + | Ampersand -> "&" | Bar -> "|" | As -> "as" | Lparen -> "(" @@ -193,7 +199,10 @@ let to_string = function | Module -> "module" | Of -> "of" | Lor -> "||" - | Band -> "&" + | Bnot -> "~~~" + | Bor -> "|||" + | Bxor -> "^^^" + | Band -> "&&&" | Caret -> "^" | Land -> "&&" | BangEqual -> "!=" diff --git a/compiler/syntax/src/res_token_debugger.ml b/compiler/syntax/src/res_token_debugger.ml index 852bc110a3..93a4b9f513 100644 --- a/compiler/syntax/src/res_token_debugger.ml +++ b/compiler/syntax/src/res_token_debugger.ml @@ -41,6 +41,7 @@ let dump_tokens filename = | Res_token.Equal -> "Equal" | Res_token.EqualEqual -> "EqualEqual" | Res_token.EqualEqualEqual -> "EqualEqualEqual" + | Res_token.Ampersand -> "Ampersand" | Res_token.Bar -> "Bar" | Res_token.Lparen -> "Lparen" | Res_token.Rparen -> "Rparen" @@ -93,7 +94,10 @@ let dump_tokens filename = | Res_token.Of -> "Of" | Res_token.Land -> "Land" | Res_token.Lor -> "Lor" + | Res_token.Bnot -> "Bnot" + | Res_token.Bor -> "Bor" | Res_token.Band -> "Band" + | Res_token.Bxor -> "Bxor" | Res_token.Caret -> "Caret" | Res_token.BangEqual -> "BangEqual" | Res_token.BangEqualEqual -> "BangEqualEqual" diff --git a/packages/@rescript/runtime/Pervasives.res b/packages/@rescript/runtime/Pervasives.res index 056d34a3be..aa686fc674 100644 --- a/packages/@rescript/runtime/Pervasives.res +++ b/packages/@rescript/runtime/Pervasives.res @@ -68,9 +68,12 @@ external \"%": ('a, 'a) => 'a = "%mod" external \"<<": ('a, 'a) => 'a = "%lsl" external mod: ('a, 'a) => 'a = "%mod" external \"**": ('a, 'a) => 'a = "%pow" -external \"~~": 'a => 'a = "%bitnot" -external \"&": ('a, 'a) => 'a = "%bitand" -external \"^": ('a, 'a) => 'a = "%bitxor" + +external \"~~~": 'a => 'a = "%bitnot" +external \"|||": ('a, 'a) => 'a = "%bitor" +external \"^^^": ('a, 'a) => 'a = "%bitxor" +external \"&&&": ('a, 'a) => 'a = "%bitand" + external \">>": ('a, 'a) => 'a = "%asr" external \">>>": ('a, 'a) => 'a = "%lsr" diff --git a/tests/syntax_tests/data/parsing/errors/scanner/expected/oldDerefOp.res.txt b/tests/syntax_tests/data/parsing/errors/scanner/expected/oldDerefOp.res.txt index 2a2dcb7c4e..6585d21608 100644 --- a/tests/syntax_tests/data/parsing/errors/scanner/expected/oldDerefOp.res.txt +++ b/tests/syntax_tests/data/parsing/errors/scanner/expected/oldDerefOp.res.txt @@ -1,23 +1,12 @@ Syntax error! - syntax_tests/data/parsing/errors/scanner/oldDerefOp.res:1:51 + syntax_tests/data/parsing/errors/scanner/oldDerefOp.res:1:50 1 │ let newVelocity = velocity +. a *. secondPerFrame^; 2 │ let newX = x +. newVelocity *. secondPerFrame^; 3 │ - Did you forget to write an expression here? + I'm not sure what to parse here when looking at "^". - - Syntax error! - syntax_tests/data/parsing/errors/scanner/oldDerefOp.res:2:47 - - 1 │ let newVelocity = velocity +. a *. secondPerFrame^; - 2 │ let newX = x +. newVelocity *. secondPerFrame^; - 3 │ - - Did you forget to write an expression here? - -let newVelocity = - (velocity +. (a *. secondPerFrame)) ^ ([%rescript.exprhole ]) -let newX = (x +. (newVelocity *. secondPerFrame)) ^ ([%rescript.exprhole ]) \ No newline at end of file +let newVelocity = velocity +. (a *. secondPerFrame) +let newX = x +. (newVelocity *. secondPerFrame) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/apply.res b/tests/syntax_tests/data/parsing/grammar/expressions/apply.res index 41b0409fc7..da787e98d4 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/apply.res +++ b/tests/syntax_tests/data/parsing/grammar/expressions/apply.res @@ -11,8 +11,8 @@ let unitUncurried = apply(.) call(~a: int) // pass the result of bitwise NOT expression -call((~a)) -call(~a=a ^ ~a) -call(~a=~a) +call(~~~a) +call(~a=a^^^~~~a) +call(~a=~~~a) call_partial(3, ...) diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/binary.res b/tests/syntax_tests/data/parsing/grammar/expressions/binary.res index 117427b110..cc341c3c1e 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/binary.res +++ b/tests/syntax_tests/data/parsing/grammar/expressions/binary.res @@ -28,8 +28,9 @@ let x = z->@attr while condition { () } let x = a + -1 + -2 let x = a + @attr -1 + @attr -2 let x = a % a == 0 -let x = a ^ a == 0 -let x = a & a == 0 +let x = a ^^^ a == 0 +let x = a &&& a == 0 +let x = a ||| a == 0 let x = a << a == 0 let x = a >> a == 0 let x = a >>> a == 0 diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt index 984c017cd8..b913ec585f 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt @@ -6,7 +6,7 @@ ;;List.reduce (fun [arity:2]acc -> fun curr -> acc + curr) 0 myList let unitUncurried = apply () ;;call ~a:(a : int) -;;call (~ a) -;;call ~a:(a ^ (~ a)) -;;call ~a:(~ a) +;;call (~~~ a) +;;call ~a:(a ^^^ (~~~ a)) +;;call ~a:(~~~ a) ;;call_partial 3 ... \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt index 93318c4482..21148778bc 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt @@ -14,8 +14,9 @@ let x = z -> ((while condition do () done)[@attr ]) let x = (a + (-1)) + (-2) let x = (a + (((-1))[@attr ])) + (((-2))[@attr ]) let x = (a % a) == 0 -let x = a ^ (a == 0) -let x = a & (a == 0) +let x = a ^^^ (a == 0) +let x = a &&& (a == 0) +let x = a ||| (a == 0) let x = (a << a) == 0 let x = (a >> a) == 0 let x = (a >>> a) == 0 diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/unary.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/unary.res.txt index debc6dd93e..0ee5c57286 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/unary.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/unary.res.txt @@ -1,15 +1,15 @@ let x = not true let m = (-1) let m = (-2.5) -let m = ~~ 2 +let m = ~~~ 2 let x = 5 let x = 5.4 let b = (-1n) let b = 1n -let m = ~~ 2n +let m = ~~~ 2n let sum = (- a) - (- b) -let bitop = (~ a) ^ (~ b) -let x = ~~ (-1n) -let x = - (~~ 1n) -let x = ~~ (-1n) -let x = - (~~ 1n) \ No newline at end of file +let bitop = (~~~ a) ^^^ (~~~ b) +let x = ~~~ (-1n) +let x = - (~~~ 1n) +let x = ~~~ (-1n) +let x = - (~~~ 1n) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/unary.res b/tests/syntax_tests/data/parsing/grammar/expressions/unary.res index 7eb5cf8366..253bffd850 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/unary.res +++ b/tests/syntax_tests/data/parsing/grammar/expressions/unary.res @@ -2,18 +2,18 @@ let x = !true let m = -1 let m = -.2.5 -let m = ~2 +let m = ~~~2 let x = +5 let x = +.5.4 let b = -1n let b = +1n -let m = ~2n +let m = ~~~2n let sum = -a - -b -let bitop = ~a ^ ~b +let bitop = ~~~a ^^^ ~~~b -let x = ~-1n -let x = -~1n -let x = ~(-1n) -let x = -(~1n) +let x = ~~~-1n +let x = -~~~1n +let x = ~~~(-1n) +let x = -(~~~1n) diff --git a/tests/syntax_tests/data/printer/expr/apply.res b/tests/syntax_tests/data/printer/expr/apply.res index 2516fa65a8..2560c4e064 100644 --- a/tests/syntax_tests/data/printer/expr/apply.res +++ b/tests/syntax_tests/data/printer/expr/apply.res @@ -5,8 +5,8 @@ let rbt = make(~compare?) let rbt = make(~compare=intCompare) let rbt = make(~compare=?intCompare) let rbt = make(~compare=?intCompare: (int, int) => int) -let rbt = make((~compare)) -let rbt = make((~-compare) ^ ~x) +let rbt = make(~~~compare) +let rbt = make(~~~-compare ^^^ ~~~x) let () = applyFunctionToArguments( superLongIdentifierWooooooowThisIsSuchLong, diff --git a/tests/syntax_tests/data/printer/expr/binary.res b/tests/syntax_tests/data/printer/expr/binary.res index 18e9a73863..8c9f2915b5 100644 --- a/tests/syntax_tests/data/printer/expr/binary.res +++ b/tests/syntax_tests/data/printer/expr/binary.res @@ -53,8 +53,9 @@ let () = (x: int)->(print_int: int => unit) x + y / z x / y + z x % y * z -x ^ y + z -x & y + z +x ^^^ y + z +x &&& y + z +x ||| y + z x << y + z x >> y + z x >>> y + z diff --git a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt index 780fb3e6ac..52d201c578 100644 --- a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt @@ -5,8 +5,8 @@ let rbt = make(~compare?) let rbt = make(~compare=intCompare) let rbt = make(~compare=?intCompare) let rbt = make(~compare=?(intCompare: (int, int) => int)) -let rbt = make((~compare)) -let rbt = make((~(-compare)) ^ (~x)) +let rbt = make(~~~compare) +let rbt = make(~~~(-compare) ^^^ ~~~x) let () = applyFunctionToArguments( superLongIdentifierWooooooowThisIsSuchLong, diff --git a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt index 60943941c1..0eae819351 100644 --- a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt @@ -72,8 +72,9 @@ let () = (x: int)->(print_int: int => unit) x + y / z x / y + z x % y * z -x ^ y + z -x & y + z +x ^^^ y + z +x &&& y + z +x ||| y + z x << y + z x >> y + z x >>> y + z diff --git a/tests/syntax_tests/data/printer/expr/expected/unary.res.txt b/tests/syntax_tests/data/printer/expr/expected/unary.res.txt index 1426841868..e3c7fd6917 100644 --- a/tests/syntax_tests/data/printer/expr/expected/unary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/unary.res.txt @@ -1,12 +1,12 @@ let x = -a let x = -.a let x = !a -let x = ~a +let x = ~~~a -let x = ~(-a) -let x = -(~a) -let x = ~(-a) -let x = -(~a) +let x = ~~~(-a) +let x = -(~~~a) +let x = ~~~(-a) +let x = -(~~~a) let isMale = !user["female"] diff --git a/tests/syntax_tests/data/printer/expr/unary.res b/tests/syntax_tests/data/printer/expr/unary.res index 69058af5c9..2f596275f7 100644 --- a/tests/syntax_tests/data/printer/expr/unary.res +++ b/tests/syntax_tests/data/printer/expr/unary.res @@ -1,12 +1,12 @@ let x = -a let x = -.a let x = !a -let x = ~a +let x = ~~~a -let x = ~-a -let x = -~a -let x = ~(-a) -let x = -(~a) +let x = ~~~-a +let x = -~~~a +let x = ~~~(-a) +let x = -(~~~a) let isMale = !user["female"] diff --git a/tests/tests/src/belt_int_test.res b/tests/tests/src/belt_int_test.res index e25de142aa..fadf1b968f 100644 --- a/tests/tests/src/belt_int_test.res +++ b/tests/tests/src/belt_int_test.res @@ -41,9 +41,9 @@ describe(__MODULE__, () => { eq(__LOC__, 2 * 3, 6) eq(__LOC__, 2 / 3, 0) eq(__LOC__, 2 % 2, 0) - eq(__LOC__, (~-2), 1) - eq(__LOC__, 2 ^ (~2), -1) - eq(__LOC__, 2 ^ 3, 1) + eq(__LOC__, ~~~-2, 1) + eq(__LOC__, 2 ^^^ ~~~2, -1) + eq(__LOC__, 2 ^^^ 3, 1) eq(__LOC__, 2 << 3, 16) eq(__LOC__, 16 >> 3, 2) eq(__LOC__, 16 >>> 3, 2) diff --git a/tests/tests/src/unified_ops_test.mjs b/tests/tests/src/unified_ops_test.mjs index 68d97b5ef9..ed61a586c9 100644 --- a/tests/tests/src/unified_ops_test.mjs +++ b/tests/tests/src/unified_ops_test.mjs @@ -75,6 +75,14 @@ function bnot_bigint(a) { return ~a; } +function bor_int(a, b) { + return a | b; +} + +function bor_bigint(a, b) { + return a | b; +} + function bxor_int(a, b) { return a ^ b; } @@ -127,6 +135,8 @@ export { pow_overflow, bnot_int, bnot_bigint, + bor_int, + bor_bigint, bxor_int, bxor_bigint, band_int, diff --git a/tests/tests/src/unified_ops_test.res b/tests/tests/src/unified_ops_test.res index 938fd9b8b8..9c8207fbb8 100644 --- a/tests/tests/src/unified_ops_test.res +++ b/tests/tests/src/unified_ops_test.res @@ -27,14 +27,17 @@ let pow3 = 2n ** 2n let pow_overflow = 2147483647 ** 2 -let bnot_int = a => ~a -let bnot_bigint = (a: bigint) => ~a +let bnot_int = a => ~~~a +let bnot_bigint = (a: bigint) => ~~~a -let bxor_int = (a, b) => a ^ b -let bxor_bigint = (a: bigint, b) => a ^ b +let bor_int = (a, b) => a ||| b +let bor_bigint = (a: bigint, b) => a ||| b -let band_int = (a, b) => a & b -let band_bigint = (a: bigint, b) => a & b +let bxor_int = (a, b) => a ^^^ b +let bxor_bigint = (a: bigint, b) => a ^^^ b + +let band_int = (a, b) => a &&& b +let band_bigint = (a: bigint, b) => a &&& b let intShiftLeft = 1 << 2 let intShiftRight = 8 >> 2