diff --git a/jscomp/core/lam.ml b/jscomp/core/lam.ml index ab59a9786c..1aef7cb127 100644 --- a/jscomp/core/lam.ml +++ b/jscomp/core/lam.ml @@ -676,7 +676,11 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t = default () let not_ loc x : t = - prim ~primitive:Pnot ~args:[x] loc + match x with + | Lprim ({primitive = Pintcomp Cneq } as prim)-> + Lprim {prim with primitive = Pintcomp Ceq} + | _ -> + prim ~primitive:Pnot ~args:[x] loc let has_boolean_type (x : t) = @@ -769,6 +773,24 @@ let if_ (a : t) (b : t) (c : t) : t = { body with sw_failaction = Some b; sw_consts_full = false; }) | _ -> Lifthenelse(a,b,c) end + | Lprim{primitive = Pisint; args = [Lvar i];_} + -> + begin match b with + | Lifthenelse(Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} , _, b_f) + when Ident.same i j && eq_approx b_f c -> + b + | Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} + when Ident.same i j && eq_approx false_ c -> b + | Lifthenelse(Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _]} as b_pred) , b_t, b_f) + when Ident.same i j && eq_approx b_t c -> + Lifthenelse(Lprim{b_pred with primitive = Pintcomp Ceq}, b_f, b_t) + | Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _] as args ; loc} ) + | Lprim( + {primitive = Pnot ; args = [Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _] as args; loc}]}) + when Ident.same i j && eq_approx true_ c + -> Lprim{primitive = Pintcomp Ceq; args; loc} + | _ -> Lifthenelse(a,b,c) + end | _ -> Lifthenelse (a,b,c)) diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index a83c8a2c41..ac55adeab5 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -333,6 +333,7 @@ o test/gpr_4494_test.cmi test/gpr_4494_test.cmj : cc test/gpr_4494_test.ml | $st o test/gpr_4519_test.cmi test/gpr_4519_test.cmj : cc test/gpr_4519_test.ml | test/mt.cmj $stdlib o test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib o test/gpr_4639_test.cmi test/gpr_4639_test.cmj : cc test/gpr_4639_test.ml | $stdlib +o test/gpr_4924_test.cmi test/gpr_4924_test.cmj : cc test/gpr_4924_test.ml | $stdlib o test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib o test/gpr_658.cmi test/gpr_658.cmj : cc test/gpr_658.ml | $stdlib o test/gpr_858_test.cmi test/gpr_858_test.cmj : cc test/gpr_858_test.ml | $stdlib diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 3777d864a5..b889aaa452 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -7103,27 +7103,20 @@ function param_list_or_type(env) { return ret; } -function postfix(env) { - var t = primary(env); - return postfix_with(env, t); -} - function prefix(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return postfix(env); - } if (match !== 76) { - return postfix(env); + var t = primary(env); + return postfix_with(env, t); } var loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, /* T_PLING */76); - var t = prefix(env); + var t$1 = prefix(env); return [ - btwn(loc, t[0]), + btwn(loc, t$1[0]), { TAG: /* Nullable */0, - _0: t + _0: t$1 } ]; } @@ -7385,7 +7378,7 @@ function union_with(env, left) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 80) { + if (match === 80) { token$4(env, /* T_BIT_OR */80); _acc = { hd: intersection(env), @@ -7459,7 +7452,7 @@ function intersection_with(env, left) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 82) { + if (match === 82) { token$4(env, /* T_BIT_AND */82); _acc = { hd: prefix(env), @@ -7593,37 +7586,21 @@ function params$1(env, allow_default, _require_default, _acc) { var id = match$1[1]; var loc = match$1[0]; var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - var match$3; - if (allow_default) { - var exit = 0; - if (typeof match$2 === "number" && match$2 === 75) { - token$3(env); - match$3 = [ - union(env), - true - ]; - } else { - exit = 1; - } - if (exit === 1) { - if (require_default) { - error_at(env, [ - loc, - /* MissingTypeParamDefault */58 - ]); - } - match$3 = [ - undefined, - require_default - ]; - } - - } else { - match$3 = [ + var match$3 = allow_default ? ( + match$2 === 75 ? (token$3(env), [ + union(env), + true + ]) : (require_default ? error_at(env, [ + loc, + /* MissingTypeParamDefault */58 + ]) : undefined, [ + undefined, + require_default + ]) + ) : [ undefined, false ]; - } var param_1 = { name: id.name, bound: id.typeAnnotation, @@ -7843,7 +7820,7 @@ function properties(allow_static, env, _param) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; var exit$1 = 0; - if ($$static && typeof match$1 === "number" && match$1 === 77) { + if ($$static && match$1 === 77) { strict_error_at(env, [ start_loc, /* StrictReservedWord */39 @@ -7995,7 +7972,7 @@ function annotation(env) { function annotation_opt(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 77) { + if (match === 77) { return annotation(env); } @@ -8780,18 +8757,11 @@ function unary(env) { function left_hand_side(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - var expr; - var exit = 0; - if (typeof match === "number" && match === 42) { - expr = _new(env, (function (new_expr, _args) { + var expr = match === 42 ? _new(env, (function (new_expr, _args) { return new_expr; - })); - } else { - exit = 1; - } - if (exit === 1) { - expr = Curry._2(Parser_env_Peek.is_function, undefined, env) ? _function$1(env) : primary$1(env); - } + })) : ( + Curry._2(Parser_env_Peek.is_function, undefined, env) ? _function$1(env) : primary$1(env) + ); var expr$1 = member(env, expr); var part = Curry._2(Parser_env_Peek.token, undefined, env); if (typeof part === "number") { @@ -8885,7 +8855,7 @@ function _new(env, _finish_fn) { while(true) { var finish_fn = _finish_fn; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 42) { + if (match === 42) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, /* T_NEW */42); var finish_fn$prime = (function(finish_fn,start_loc){ @@ -8922,7 +8892,7 @@ function _new(env, _finish_fn) { var callee$1; callee$1 = typeof part === "number" || part.TAG !== /* T_TEMPLATE_PART */2 ? callee : tagged_template(env, callee, part._0); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var args = typeof match$1 === "number" && match$1 === 3 ? Curry._1($$arguments, env) : undefined; + var args = match$1 === 3 ? Curry._1($$arguments, env) : undefined; return Curry._2(finish_fn, callee$1, args); }; } @@ -8987,7 +8957,7 @@ function _function$1(env) { ]; } else { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var id = typeof match$1 === "number" && match$1 === 89 ? undefined : Curry._2(Parse.identifier, /* StrictFunctionName */30, env); + var id = match$1 === 89 ? undefined : Curry._2(Parse.identifier, /* StrictFunctionName */30, env); match = [ id, Curry._1(type_parameter_declaration$1, env) @@ -9393,7 +9363,7 @@ function sequence(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 8) { + if (match === 8) { token$4(env, /* T_COMMA */8); var expr = Curry._1(assignment, env); _acc = { @@ -9663,12 +9633,6 @@ function logical_and(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return [ - lloc, - left - ]; - } if (match !== 79) { return [ lloc, @@ -9689,12 +9653,6 @@ function logical_or(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return [ - lloc, - left - ]; - } if (match !== 78) { return [ lloc, @@ -10054,12 +10012,6 @@ function binary(env) { function argument(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return { - TAG: /* Expression */0, - _0: Curry._1(assignment, env) - }; - } if (match !== 11) { return { TAG: /* Expression */0, @@ -10129,7 +10081,7 @@ function template_parts(env, _quasis, _expressions) { tl: expressions }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 2) { + if (match === 2) { push_lex_mode(env, /* TEMPLATE */4); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; @@ -10412,7 +10364,7 @@ function try_arrow_function(env) { var generator = false; var env = with_in_function(true, param); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 1) { + if (match === 1) { var match$1 = function_body(env, async, generator); return [ match$1[1], @@ -10461,9 +10413,6 @@ function decorator_list_helper(env, _decorators) { while(true) { var decorators = _decorators; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return decorators; - } if (match !== 12) { return decorators; } @@ -11097,9 +11046,6 @@ function class_implements(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return List.rev(acc$1); - } if (match !== 8) { return List.rev(acc$1); } @@ -12252,9 +12198,6 @@ function supers(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return List.rev(acc$1); - } if (match !== 8) { return List.rev(acc$1); } @@ -12296,9 +12239,6 @@ function supers$1(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return List.rev(acc$1); - } if (match !== 8) { return List.rev(acc$1); } @@ -12549,7 +12489,7 @@ function case_list(env, _param) { } var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var test = typeof match$1 === "number" && match$1 === 34 ? (seen_default ? error$1(env, /* MultipleDefaultsInSwitch */19) : undefined, token$4(env, /* T_DEFAULT */34), undefined) : (token$4(env, /* T_CASE */31), Curry._1(Parse.expression, env)); + var test = match$1 === 34 ? (seen_default ? error$1(env, /* MultipleDefaultsInSwitch */19) : undefined, token$4(env, /* T_DEFAULT */34), undefined) : (token$4(env, /* T_CASE */31), Curry._1(Parse.expression, env)); var seen_default$1 = seen_default || test === undefined; var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, /* T_COLON */77); @@ -12706,7 +12646,7 @@ function specifier_list(env, _acc) { function named_or_namespace_specifier(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 97) { + if (match === 97) { token$4(env, /* T_MULT */97); contextual(env, "as"); var id = Curry._2(Parse.identifier, undefined, env); @@ -12921,17 +12861,13 @@ function _object$2(restricted_error) { } var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var prop; - var exit = 0; - if (typeof match$1 === "number" && match$1 === 77) { + if (match$1 === 77) { token$4(env, /* T_COLON */77); prop = [ pattern$1(env, restricted_error), false ]; } else { - exit = 1; - } - if (exit === 1) { switch (key.TAG | 0) { case /* Identifier */1 : var id = key._0; @@ -12963,7 +12899,7 @@ function _object$2(restricted_error) { var pattern$3 = prop[0]; var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$4; - if (typeof match$2 === "number" && match$2 === 75) { + if (match$2 === 75) { token$4(env, /* T_ASSIGN */75); var $$default = Curry._1(Parse.assignment, env); var loc$1 = btwn(pattern$3[0], $$default[0]); @@ -13109,7 +13045,7 @@ function _array(restricted_error) { var pattern$2 = pattern$1(env, restricted_error); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$3; - if (typeof match$1 === "number" && match$1 === 75) { + if (match$1 === 75) { token$4(env, /* T_ASSIGN */75); var $$default = Curry._1(Parse.expression, env); var loc$1 = btwn(pattern$2[0], $$default[0]); @@ -13254,9 +13190,6 @@ function member_expression(env, _member) { while(true) { var member = _member; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number") { - return member; - } if (match !== 9) { return member; } @@ -13782,7 +13715,7 @@ function statement(env) { var block = Curry._1(Parse.block_body, env); var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var handler; - if (typeof match$2 === "number" && match$2 === 32) { + if (match$2 === 32) { var start_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, /* T_CATCH */32); token$4(env, /* T_LPAREN */3); @@ -13811,7 +13744,7 @@ function statement(env) { handler = undefined; } var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); - var finalizer = typeof match$3 === "number" && match$3 === 36 ? (token$4(env, /* T_FINALLY */36), Curry._1(Parse.block_body, env)) : undefined; + var finalizer = match$3 === 36 ? (token$4(env, /* T_FINALLY */36), Curry._1(Parse.block_body, env)) : undefined; var end_loc$3 = finalizer !== undefined ? finalizer[0] : ( handler !== undefined ? handler[0] : (error_at(env, [ block[0], @@ -14130,10 +14063,10 @@ function statement(env) { }), match$5[1]); token$4(env, /* T_SEMICOLON */7); var match$10 = Curry._2(Parser_env_Peek.token, undefined, env); - var test$2 = typeof match$10 === "number" && match$10 === 7 ? undefined : Curry._1(Parse.expression, env); + var test$2 = match$10 === 7 ? undefined : Curry._1(Parse.expression, env); token$4(env, /* T_SEMICOLON */7); var match$11 = Curry._2(Parser_env_Peek.token, undefined, env); - var update = typeof match$11 === "number" && match$11 === 4 ? undefined : Curry._1(Parse.expression, env); + var update = match$11 === 4 ? undefined : Curry._1(Parse.expression, env); token$4(env, /* T_RPAREN */4); var body$6 = Curry._1(Parse.statement, with_in_loop(true, env)); return [ @@ -14222,7 +14155,7 @@ function statement(env) { var match$12 = Curry._2(Parser_env_Peek.token, undefined, env); var label$4 = expr$1[1]; var loc$11 = expr$1[0]; - if (typeof label$4 !== "number" && label$4.TAG === /* Identifier */18 && typeof match$12 === "number" && match$12 === 77) { + if (typeof label$4 !== "number" && label$4.TAG === /* Identifier */18 && match$12 === 77) { var label$5 = label$4._0; var match$13 = label$5[1]; var name$2 = match$13.name; @@ -14497,8 +14430,7 @@ function module_item(env) { ]); var match$4 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$5; - var exit$1 = 0; - if (typeof match$4 === "number" && match$4 === 13) { + if (match$4 === 13) { var fn = _function(env$1); match$5 = [ fn[0], @@ -14507,32 +14439,27 @@ function module_item(env) { _0: fn } ]; + } else if (Curry._2(Parser_env_Peek.is_class, undefined, env$1)) { + var _class = class_declaration(env$1, decorators); + match$5 = [ + _class[0], + { + TAG: /* Declaration */0, + _0: _class + } + ]; } else { - exit$1 = 3; - } - if (exit$1 === 3) { - if (Curry._2(Parser_env_Peek.is_class, undefined, env$1)) { - var _class = class_declaration(env$1, decorators); - match$5 = [ - _class[0], - { - TAG: /* Declaration */0, - _0: _class - } - ]; - } else { - var expr = Curry._1(Parse.assignment, env$1); - var loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - var end_loc$3 = loc$2 !== undefined ? loc$2 : expr[0]; - semicolon(env$1); - match$5 = [ - end_loc$3, - { - TAG: /* Expression */1, - _0: expr - } - ]; - } + var expr = Curry._1(Parse.assignment, env$1); + var loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + var end_loc$3 = loc$2 !== undefined ? loc$2 : expr[0]; + semicolon(env$1); + match$5 = [ + end_loc$3, + { + TAG: /* Expression */1, + _0: expr + } + ]; } return [ btwn(start_loc, match$5[0]), @@ -14587,7 +14514,7 @@ function module_item(env) { switch (exit) { case 1 : var match$6 = Curry._2(Parser_env_Peek.token, undefined, env$1); - var exportKind = typeof match$6 === "number" && match$6 === 59 ? (token$3(env$1), /* ExportType */0) : /* ExportValue */1; + var exportKind = match$6 === 59 ? (token$3(env$1), /* ExportType */0) : /* ExportValue */1; token$4(env$1, /* T_LCURLY */1); var match$7 = export_specifiers_and_errs(env$1, /* [] */0, /* [] */0); var specifiers$1 = { @@ -14732,13 +14659,13 @@ function module_item(env) { var importKind = match$10[0]; var match$11 = Curry._2(Parser_env_Peek.token, undefined, env$2); var match$12 = Curry._2(Parser_env_Peek.is_identifier, undefined, env$2); + var exit$1 = 0; var exit$2 = 0; - var exit$3 = 0; if (typeof match$11 === "number") { if (match$11 === /* T_COMMA */8) { - exit$2 = 1; + exit$1 = 1; } else { - exit$3 = 2; + exit$2 = 2; } } else if (match$11.TAG === /* T_STRING */1) { if (importKind === /* ImportValue */2) { @@ -14786,13 +14713,13 @@ function module_item(env) { } ]; } - exit$3 = 2; + exit$2 = 2; } else { - exit$3 = 2; + exit$2 = 2; } - if (exit$3 === 2) { + if (exit$2 === 2) { if (match$12) { - exit$2 = 1; + exit$1 = 1; } else { var specifiers$2 = named_or_namespace_specifier(env$2); var source$5 = source(env$2); @@ -14812,11 +14739,11 @@ function module_item(env) { ]; } } - if (exit$2 === 1) { + if (exit$1 === 1) { var match$14 = Curry._2(Parser_env_Peek.token, undefined, env$2); var match$15 = Curry._2(Parser_env_Peek.value, undefined, env$2); var match$16; - var exit$4 = 0; + var exit$3 = 0; if (type_ident !== undefined && typeof match$14 === "number" && !(match$14 !== 8 && (match$14 !== 0 || match$15 !== "from"))) { match$16 = [ /* ImportValue */2, @@ -14826,9 +14753,9 @@ function module_item(env) { } ]; } else { - exit$4 = 2; + exit$3 = 2; } - if (exit$4 === 2) { + if (exit$3 === 2) { match$16 = [ importKind, { @@ -14838,7 +14765,7 @@ function module_item(env) { ]; } var match$17 = Curry._2(Parser_env_Peek.token, undefined, env$2); - var additional_specifiers = typeof match$17 === "number" && match$17 === 8 ? (token$4(env$2, /* T_COMMA */8), named_or_namespace_specifier(env$2)) : /* [] */0; + var additional_specifiers = match$17 === 8 ? (token$4(env$2, /* T_COMMA */8), named_or_namespace_specifier(env$2)) : /* [] */0; var source$6 = source(env$2); var loc$7 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); var end_loc$8 = loc$7 !== undefined ? loc$7 : source$6[0]; @@ -14980,7 +14907,7 @@ function statement_list(_env, term_fn, item_fn, _param) { var stmts = param[1]; var string_tokens = param[0]; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "number" && t === 105) { + if (t === 105) { return [ env, string_tokens, @@ -15103,7 +15030,7 @@ function statement_list$1(term_fn, env) { while(true) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "number" && t === 105) { + if (t === 105) { return List.rev(acc); } if (Curry._1(term_fn, t)) { @@ -15122,7 +15049,7 @@ function module_body(term_fn, env) { while(true) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "number" && t === 105) { + if (t === 105) { return List.rev(acc); } if (Curry._1(term_fn, t)) { @@ -15151,8 +15078,7 @@ function identifier$2(restricted_error, env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var name = Curry._2(Parser_env_Peek.value, undefined, env); var t = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - if (typeof t === "number" && t === 26) { + if (t === 26) { if (env.in_strict_mode) { strict_error(env, /* StrictReservedWord */39); } else if (env.no_let) { @@ -15162,18 +15088,13 @@ function identifier$2(restricted_error, env) { }); } token$3(env); + } else if (is_strict_reserved(name)) { + strict_error(env, /* StrictReservedWord */39); + token$3(env); + } else if (typeof t === "number" && !(t > 62 || t < 58)) { + token$4(env, t); } else { - exit = 1; - } - if (exit === 1) { - if (is_strict_reserved(name)) { - strict_error(env, /* StrictReservedWord */39); - token$3(env); - } else if (typeof t === "number" && !(t > 62 || t < 58)) { - token$4(env, t); - } else { - token$4(env, /* T_IDENTIFIER */0); - } + token$4(env, /* T_IDENTIFIER */0); } if (restricted_error !== undefined && is_restricted(name)) { strict_error_at(env, [ @@ -15227,7 +15148,7 @@ function program(env) { function expression$1(env) { var expr = Curry._1(assignment, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && match === 8) { + if (match === 8) { return sequence(env, { hd: expr, tl: /* [] */0 diff --git a/jscomp/test/gpr_1658_test.js b/jscomp/test/gpr_1658_test.js index 4b159957f9..04ba64cd64 100644 --- a/jscomp/test/gpr_1658_test.js +++ b/jscomp/test/gpr_1658_test.js @@ -33,7 +33,7 @@ eq("File \"gpr_1658_test.ml\", line 11, characters 7-14", null, null); var match = Js_types.classify(null); -if (typeof match === "number" && match === 2) { +if (match === 2) { eq("File \"gpr_1658_test.ml\", line 14, characters 11-18", true, true); } else { eq("File \"gpr_1658_test.ml\", line 16, characters 11-18", true, false); diff --git a/jscomp/test/gpr_4924_test.js b/jscomp/test/gpr_4924_test.js new file mode 100644 index 0000000000..aae5260483 --- /dev/null +++ b/jscomp/test/gpr_4924_test.js @@ -0,0 +1,51 @@ +'use strict'; + + +function u(b) { + if (b === 0) { + return 0; + } else { + return 1; + } +} + +function u1(b) { + return b === 0; +} + +function u2(b) { + return b === 0; +} + +function u3(b) { + if (b === 0) { + return 3; + } else { + return 4; + } +} + +function u4(b) { + if (b === 0) { + return 3; + } else { + return 4; + } +} + +function u5(b) { + return b !== 0; +} + +function u6(b) { + return b === 0; +} + +exports.u = u; +exports.u1 = u1; +exports.u2 = u2; +exports.u3 = u3; +exports.u4 = u4; +exports.u5 = u5; +exports.u6 = u6; +/* No side effect */ diff --git a/jscomp/test/gpr_4924_test.ml b/jscomp/test/gpr_4924_test.ml new file mode 100644 index 0000000000..23d494c1f3 --- /dev/null +++ b/jscomp/test/gpr_4924_test.ml @@ -0,0 +1,39 @@ +type t = + | A + | B + | C of int +let u b = + match b with + | A -> 0 + | B | C _ -> 1 + +let u1 b = + match b with + | A -> true + | B | C _ -> false + + +let u2 b = + match b with + | A -> false + | B | C _ -> true + +let u3 b = + match b with + | A -> 3 + | B | C _ -> 4 + +let u4 b = + match b with + | A -> 3 + | _ -> 4 + +let u5 b = + match b with + | A -> false + | _ -> true + +let u6 b = + match b with + | A -> true + | _ -> false diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 8bb09d1626..f76151ad04 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -1352,11 +1352,7 @@ function kill(collid, ctx) { } case /* Block */3 : var o$2 = collid._2; - var t = collid._0; - if (typeof t !== "number") { - return /* [] */0; - } - if (t !== 1) { + if (collid._0 !== 1) { return /* [] */0; } var pos_0$1 = o$2.pos.x; @@ -1684,72 +1680,64 @@ function process_collision(dir, c1, c2, state) { var o2$4 = c2._2; var t = c2._0; if (dir !== 0) { - var exit$1 = 0; - if (typeof t === "number" && t === 4) { + if (t === 4) { game_win(state.ctx); return [ undefined, undefined ]; + } else if (dir !== 1) { + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; + } else { + state.multiplier = 1; + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; } - exit$1 = 4; - if (exit$1 === 4) { - if (dir !== 1) { - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } else { - state.multiplier = 1; - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } - } - - } else { - if (typeof t === "number") { - if (t !== 1) { - if (t !== 4) { - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } else { - game_win(state.ctx); - return [ - undefined, - undefined - ]; - } - } else if (c1._0 === /* BigM */0) { + } + if (typeof t === "number") { + if (t !== 1) { + if (t !== 4) { collide_block(undefined, dir, o1$3); - dec_health(o2$4); return [ undefined, undefined ]; } else { - collide_block(undefined, dir, o1$3); + game_win(state.ctx); return [ undefined, undefined ]; } + } else if (c1._0 === /* BigM */0) { + collide_block(undefined, dir, o1$3); + dec_health(o2$4); + return [ + undefined, + undefined + ]; + } else { + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; } - var updated_block = evolve_block(o2$4, context); - var spawned_item = spawn_above(o1$3.dir, o2$4, t._0, context); - collide_block(undefined, dir, o1$3); - return [ - spawned_item, - updated_block - ]; } - break; + var updated_block = evolve_block(o2$4, context); + var spawned_item = spawn_above(o1$3.dir, o2$4, t._0, context); + collide_block(undefined, dir, o1$3); + return [ + spawned_item, + updated_block + ]; } break; diff --git a/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/ocaml_parsetree_test.js index f6ccd4d62e..eb009ae8e9 100644 --- a/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/ocaml_parsetree_test.js @@ -11265,11 +11265,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_or_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 8) { - push(e); - return v; - } + if (e === 8) { var calc$1 = calc && !v; var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); if (v) { @@ -11291,15 +11287,7 @@ function directive_parse(token_with_comments, lexbuf) { case /* LPAREN */54 : var v = parse_or_aux(calc, parse_and_aux(calc, parse_relation(calc))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 81) { - throw { - RE_EXN_ID: $$Error$2, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 81) { return v; } throw { @@ -11435,11 +11423,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_and_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 0) { - push(e); - return v; - } + if (e === 0) { var calc$1 = calc && v; var b = parse_and_aux(calc$1, parse_relation(calc$1)); if (v) { @@ -11453,15 +11437,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 88) { - throw { - RE_EXN_ID: $$Error$2, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 88) { return v; } throw { @@ -12903,13 +12879,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === $$Error$2) { - var match$1 = exn._1; - if (typeof match$1 === "number") { - if (match$1 !== 0) { - throw exn; - } - var match$2 = comment_start_loc.contents; - if (match$2) { + if (exn._1 === 0) { + var match$1 = comment_start_loc.contents; + if (match$1) { var start = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -12919,7 +12891,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start, _1: exn._2 }, - _2: match$2.hd, + _2: match$1.hd, Error: new Error() }; } @@ -12953,13 +12925,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.RE_EXN_ID === $$Error$2) { - var match$3 = exn$1._1; - if (typeof match$3 === "number") { - if (match$3 !== 0) { - throw exn$1; - } - var match$4 = comment_start_loc.contents; - if (match$4) { + if (exn$1._1 === 0) { + var match$2 = comment_start_loc.contents; + if (match$2) { var start$1 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -12969,7 +12937,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start$1, _1: exn$1._2 }, - _2: match$4.hd, + _2: match$2.hd, Error: new Error() }; } @@ -12999,8 +12967,8 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { ___ocaml_lex_state = 132; continue ; case 10 : - var match$5 = comment_start_loc.contents; - if (match$5) { + var match$3 = comment_start_loc.contents; + if (match$3) { var start$2 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -13009,7 +12977,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { TAG: /* Unterminated_comment */2, _0: start$2 }, - _2: match$5.hd, + _2: match$3.hd, Error: new Error() }; } diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 2321b0238a..478838939f 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -1918,59 +1918,23 @@ function equal$2(_x1, _x2) { if (typeof x1 === "number") { switch (x1) { case /* Beg_of_line */0 : - if (typeof x2 === "number") { - return x2 === 0; - } else { - return false; - } + return x2 === 0; case /* End_of_line */1 : - if (typeof x2 === "number") { - return x2 === 1; - } else { - return false; - } + return x2 === 1; case /* Beg_of_word */2 : - if (typeof x2 === "number") { - return x2 === 2; - } else { - return false; - } + return x2 === 2; case /* End_of_word */3 : - if (typeof x2 === "number") { - return x2 === 3; - } else { - return false; - } + return x2 === 3; case /* Not_bound */4 : - if (typeof x2 === "number") { - return x2 === 4; - } else { - return false; - } + return x2 === 4; case /* Beg_of_str */5 : - if (typeof x2 === "number") { - return x2 === 5; - } else { - return false; - } + return x2 === 5; case /* End_of_str */6 : - if (typeof x2 === "number") { - return x2 === 6; - } else { - return false; - } + return x2 === 6; case /* Last_end_of_line */7 : - if (typeof x2 === "number") { - return x2 === 7; - } else { - return false; - } + return x2 === 7; case /* Start */8 : - if (typeof x2 === "number") { - return x2 === 8; - } else { - return false; - } + return x2 === 8; case /* Stop */9 : if (typeof x2 === "number") { return x2 >= 9; diff --git a/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/ocaml_typedtree_test.js index 9835bb347a..cf3b685101 100644 --- a/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/ocaml_typedtree_test.js @@ -22494,11 +22494,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_and_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 0) { - push(e); - return v; - } + if (e === 0) { var calc$1 = calc && v; var b = parse_and_aux(calc$1, parse_relation(calc$1)); if (v) { @@ -22520,15 +22516,7 @@ function directive_parse(token_with_comments, lexbuf) { case /* LPAREN */54 : var v = parse_or_aux(calc, parse_and_aux(calc, parse_relation(calc))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 81) { - throw { - RE_EXN_ID: $$Error$4, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 81) { return v; } throw { @@ -22671,11 +22659,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_or_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 8) { - push(e); - return v; - } + if (e === 8) { var calc$1 = calc && !v; var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); if (v) { @@ -22689,15 +22673,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 88) { - throw { - RE_EXN_ID: $$Error$4, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 88) { return v; } throw { @@ -24200,13 +24176,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === $$Error$4) { - var match$1 = exn._1; - if (typeof match$1 === "number") { - if (match$1 !== 0) { - throw exn; - } - var match$2 = comment_start_loc.contents; - if (match$2) { + if (exn._1 === 0) { + var match$1 = comment_start_loc.contents; + if (match$1) { var start = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -24216,7 +24188,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start, _1: exn._2 }, - _2: match$2.hd, + _2: match$1.hd, Error: new Error() }; } @@ -24250,13 +24222,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.RE_EXN_ID === $$Error$4) { - var match$3 = exn$1._1; - if (typeof match$3 === "number") { - if (match$3 !== 0) { - throw exn$1; - } - var match$4 = comment_start_loc.contents; - if (match$4) { + if (exn$1._1 === 0) { + var match$2 = comment_start_loc.contents; + if (match$2) { var start$1 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -24266,7 +24234,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start$1, _1: exn$1._2 }, - _2: match$4.hd, + _2: match$2.hd, Error: new Error() }; } @@ -24296,8 +24264,8 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { ___ocaml_lex_state = 132; continue ; case 10 : - var match$5 = comment_start_loc.contents; - if (match$5) { + var match$3 = comment_start_loc.contents; + if (match$3) { var start$2 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -24306,7 +24274,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { TAG: /* Unterminated_comment */2, _0: start$2 }, - _2: match$5.hd, + _2: match$3.hd, Error: new Error() }; } @@ -27304,11 +27272,7 @@ function in_pervasives(p) { function is_datatype(decl) { var match = decl.type_kind; - if (typeof match === "number") { - return match !== 0; - } else { - return true; - } + return match === 0; } function object_fields(ty) { @@ -30103,11 +30067,7 @@ function generic_abbrev(env, path) { function generic_private_abbrev(env, path) { try { var match = find_type_full(path, env)[0]; - var match$1 = match.type_kind; - if (typeof match$1 !== "number") { - return false; - } - if (match$1 !== 0) { + if (match.type_kind !== 0) { return false; } if (match.type_private) { @@ -31165,22 +31125,13 @@ function mcomp(type_pairs, env, _t1, _t2) { var exit$4 = 0; if (typeof match$4 === "number") { if (match$4 === /* Type_abstract */0) { - var exit$5 = 0; - if (typeof match$5 === "number") { - if (match$5 === 0) { - return ; - } - exit$5 = 2; - } else { - exit$5 = 2; + if (match$5 === 0) { + return ; } - if (exit$5 === 2) { - if (!non_aliasable(p1, decl)) { - return ; - } - exit$4 = 1; + if (!non_aliasable(p1, decl)) { + return ; } - + exit$4 = 1; } else if (typeof match$5 === "number") { if (match$5 !== 0) { return mcomp_list(type_pairs, env, tl1, tl2); @@ -31282,14 +31233,7 @@ function mcomp(type_pairs, env, _t1, _t2) { }; } if (exit$4 === 1) { - if (typeof match$5 === "number") { - if (match$5 !== 0) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } + if (match$5 === 0) { if (!non_aliasable(p2, decl$prime)) { return ; } @@ -31567,9 +31511,9 @@ function mcomp(type_pairs, env, _t1, _t2) { case /* Tpoly */10 : var tl1$1 = match$2._1; var t1$2 = match$2._0; - var exit$6 = 0; + var exit$5 = 0; if (tl1$1) { - exit$6 = 4; + exit$5 = 4; } else { if (typeof match$3 === "number") { throw { @@ -31584,7 +31528,7 @@ function mcomp(type_pairs, env, _t1, _t2) { break; case /* Tpoly */10 : if (match$3._1) { - exit$6 = 4; + exit$5 = 4; } else { _t2 = match$3._0; _t1 = t1$2; @@ -31599,7 +31543,7 @@ function mcomp(type_pairs, env, _t1, _t2) { }; } } - if (exit$6 === 4) { + if (exit$5 === 4) { if (typeof match$3 === "number") { throw { RE_EXN_ID: Unify, @@ -31751,15 +31695,8 @@ function mcomp_kind(k1, k2) { Error: new Error() }; } - if (typeof k2$1 === "number") { - if (k2$1 === 0) { - return ; - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + if (k2$1 === 0) { + return ; } throw { RE_EXN_ID: Unify, @@ -32038,14 +31975,7 @@ function complete_type_list(allow_absentOpt, env, nl1, lv2, mty2, nl2, tl2) { Error: new Error() }; } - var match$1 = decl.type_kind; - if (typeof match$1 === "number") { - if (match$1 !== 0) { - throw { - RE_EXN_ID: Pervasives.Exit, - Error: new Error() - }; - } + if (decl.type_kind === 0) { if (decl.type_private) { var t2 = decl.type_manifest; if (t2 !== undefined) { @@ -34704,15 +34634,8 @@ function moregen_kind(k1, k2) { Error: new Error() }; } - if (typeof k2$1 === "number") { - if (k2$1 === 0) { - return ; - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + if (k2$1 === 0) { + return ; } throw { RE_EXN_ID: Unify, @@ -35591,15 +35514,8 @@ function eqtype_kind(k1, k2) { Error: new Error() }; } - if (typeof k2$1 === "number") { - if (k2$1 === 0) { - return ; - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + if (k2$1 === 0) { + return ; } throw { RE_EXN_ID: Unify, @@ -45534,7 +45450,7 @@ function tree_of_typobject(sch, fi, nm) { var match = flatten_fields(fi); var present_fields = List.fold_right((function (param, l) { var match = field_kind_repr(param[1]); - if (typeof match === "number" && match === 0) { + if (match === 0) { return { hd: [ param[0], @@ -45966,12 +45882,6 @@ function value_description$1(id, ppf, decl) { function method_type(param) { var match = field_kind_repr(param[1]); var match$1 = repr(param[2]); - if (typeof match !== "number") { - return [ - match$1, - /* [] */0 - ]; - } if (match !== 0) { return [ match$1, @@ -49584,56 +49494,50 @@ function type_declarations$1(equalityOpt, env, name, decl1, id, decl2) { var match = decl1.type_kind; var match$1 = decl2.type_kind; var err; - var exit = 0; - if (typeof match$1 === "number" && match$1 === 0) { + if (match$1 === 0) { err = /* [] */0; - } else { - exit = 1; - } - if (exit === 1) { - if (typeof match === "number") { - err = match === /* Type_abstract */0 || typeof match$1 !== "number" ? ({ - hd: /* Kind */2, - tl: /* [] */0 - }) : /* [] */0; - } else if (match.TAG === /* Type_record */0) { - if (typeof match$1 === "number" || match$1.TAG !== /* Type_record */0) { - err = { + } else if (typeof match === "number") { + err = match === /* Type_abstract */0 || typeof match$1 !== "number" ? ({ hd: /* Kind */2, tl: /* [] */0 - }; - } else { - var rep2 = match$1._1; - var err$1 = compare_records(env, decl1, decl2, 1, match._0, match$1._0); - err = err$1 !== /* [] */0 || match._1 === rep2 ? err$1 : ({ - hd: { - TAG: /* Record_representation */5, - _0: rep2 === /* Record_float */1 - }, - tl: /* [] */0 - }); - } + }) : /* [] */0; + } else if (match.TAG === /* Type_record */0) { + if (typeof match$1 === "number" || match$1.TAG !== /* Type_record */0) { + err = { + hd: /* Kind */2, + tl: /* [] */0 + }; } else { - var cstrs1 = match._0; - if (typeof match$1 === "number" || match$1.TAG === /* Type_record */0) { - err = { - hd: /* Kind */2, - tl: /* [] */0 - }; - } else { - var cstrs2 = match$1._0; - var mark = function (cstrs, usage, name, decl) { - return List.iter((function (c) { - return mark_constructor_used(usage, env, name, decl, c.cd_id.name); - }), cstrs); - }; - var usage = decl1.type_private === /* Private */0 || decl2.type_private === /* Public */1 ? /* Positive */0 : /* Privatize */2; - mark(cstrs1, usage, name, decl1); - if (equality) { - mark(cstrs2, /* Positive */0, id.name, decl2); - } - err = compare_variants(env, decl1, decl2, 1, cstrs1, cstrs2); + var rep2 = match$1._1; + var err$1 = compare_records(env, decl1, decl2, 1, match._0, match$1._0); + err = err$1 !== /* [] */0 || match._1 === rep2 ? err$1 : ({ + hd: { + TAG: /* Record_representation */5, + _0: rep2 === /* Record_float */1 + }, + tl: /* [] */0 + }); + } + } else { + var cstrs1 = match._0; + if (typeof match$1 === "number" || match$1.TAG === /* Type_record */0) { + err = { + hd: /* Kind */2, + tl: /* [] */0 + }; + } else { + var cstrs2 = match$1._0; + var mark = function (cstrs, usage, name, decl) { + return List.iter((function (c) { + return mark_constructor_used(usage, env, name, decl, c.cd_id.name); + }), cstrs); + }; + var usage = decl1.type_private === /* Private */0 || decl2.type_private === /* Public */1 ? /* Positive */0 : /* Privatize */2; + mark(cstrs1, usage, name, decl1); + if (equality) { + mark(cstrs2, /* Positive */0, id.name, decl2); } + err = compare_variants(env, decl1, decl2, 1, cstrs1, cstrs2); } } if (err !== /* [] */0) { @@ -50345,12 +50249,8 @@ function contains_type_sig(env) { switch (param.TAG | 0) { case /* Sig_type */1 : var match = param._1; - var match$1 = match.type_kind; if (match.type_manifest !== undefined) { - if (typeof match$1 !== "number") { - return ; - } - if (match$1 !== 0) { + if (match.type_kind !== 0) { return ; } if (match.type_private) { @@ -72556,7 +72456,7 @@ function find$6(x, _param) { function check_coherence(env, loc, id, decl) { var match = decl.type_kind; - if (typeof match === "number" && match === 0) { + if (match === 0) { return ; } var ty = decl.type_manifest; @@ -73631,11 +73531,7 @@ function check_duplicates(sdecl_list) { } function name_recursion(sdecl, id, decl) { - var match = decl.type_kind; - if (typeof match !== "number") { - return decl; - } - if (match !== 0) { + if (decl.type_kind !== 0) { return decl; } if (decl.type_private) { @@ -81554,9 +81450,8 @@ function merge_constraint(initial_env, loc, sg, constr) { switch (constr.TAG | 0) { case /* Pwith_type */0 : var sdecl = constr._1; - var match = sdecl.ptype_kind; var exit$1 = 0; - if (typeof match === "number" && match === 0) { + if (sdecl.ptype_kind === 0) { if (id.name === s && is_fixed_type(sdecl)) { var decl_row_type_params = List.map((function (param) { return newty2(100000000, { @@ -81754,9 +81649,9 @@ function merge_constraint(initial_env, loc, sg, constr) { case /* Pwith_module */1 : var lid$prime = constr._1; if (id$1.name === s$1) { - var match$1 = find_module$1(initial_env, loc, lid$prime.txt); - var md$prime = match$1[1]; - var path = match$1[0]; + var match = find_module$1(initial_env, loc, lid$prime.txt); + var md$prime = match[1]; + var path = match[0]; var md$prime$prime_md_type = remove_aliases$1(env, md$prime.md_type); var md$prime$prime_md_attributes = md$prime.md_attributes; var md$prime$prime_md_loc = md$prime.md_loc; @@ -81800,9 +81695,9 @@ function merge_constraint(initial_env, loc, sg, constr) { case /* Pwith_modsubst */3 : var lid$prime$1 = constr._1; if (id$1.name === s$1) { - var match$2 = find_module$1(initial_env, loc, lid$prime$1.txt); - var path$1 = match$2[0]; - var newmd$1 = strengthen_decl(env, match$2[1], path$1); + var match$1 = find_module$1(initial_env, loc, lid$prime$1.txt); + var path$1 = match$1[0]; + var newmd$1 = strengthen_decl(env, match$1[1], path$1); modtypes$1(env, newmd$1.md_type, md.md_type); real_id.contents = id$1; return [ @@ -81827,13 +81722,13 @@ function merge_constraint(initial_env, loc, sg, constr) { } } if (exit$2 === 2 && id$1.name === s$1) { - var match$3 = merge(env, extract_sig(env, loc, md.md_type), namelist$1, undefined); - var match$4 = match$3[0]; + var match$2 = merge(env, extract_sig(env, loc, md.md_type), namelist$1, undefined); + var match$3 = match$2[0]; return [ [ - path_concat(id$1, match$4[0]), + path_concat(id$1, match$3[0]), lid, - match$4[2] + match$3[2] ], { hd: { @@ -81842,7 +81737,7 @@ function merge_constraint(initial_env, loc, sg, constr) { _1: { md_type: { TAG: /* Mty_signature */1, - _0: match$3[1] + _0: match$2[1] }, md_attributes: md.md_attributes, md_loc: md.md_loc @@ -81859,12 +81754,12 @@ function merge_constraint(initial_env, loc, sg, constr) { default: } - var match$5 = merge(add_item(item, env), sg.tl, namelist, row_id); + var match$4 = merge(add_item(item, env), sg.tl, namelist, row_id); return [ - match$5[0], + match$4[0], { hd: item, - tl: match$5[1] + tl: match$4[1] } ]; } @@ -84582,8 +84477,7 @@ function type_structure(toplevelOpt, funct_body, anchor, env, sstr, scope) { sg$1 = List.map((function (it) { switch (it.TAG | 0) { case /* Sig_value */0 : - var match = it._1.val_kind; - if (typeof match === "number" && match === 0) { + if (it._1.val_kind === 0) { pos.contents = pos.contents + 1 | 0; return it; } else { @@ -85916,430 +85810,410 @@ if (match$1) { var match$11 = match$9.loc_end; if (match$11.pos_fname === "" && !(match$11.pos_lnum !== 2 || match$11.pos_bol !== 1 || match$11.pos_cnum !== 9 || match$9.loc_ghost || match$5.typ_params)) { var match$12 = match$5.typ_type; - if (match$12.type_params || match$12.type_arity !== 0) { + if (match$12.type_params || match$12.type_arity !== 0 || !(match$12.type_kind === 0 && match$12.type_private && !(match$12.type_manifest !== undefined || match$12.type_variance || match$12.type_newtype_level !== undefined))) { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } else { - var match$13 = match$12.type_kind; - if (typeof match$13 === "number" && !(match$13 !== 0 || !(match$12.type_private && !(match$12.type_manifest !== undefined || match$12.type_variance || match$12.type_newtype_level !== undefined)))) { - var match$14 = match$12.type_loc; - var match$15 = match$14.loc_start; - if (match$15.pos_fname === "" && !(match$15.pos_lnum !== 2 || match$15.pos_bol !== 1 || match$15.pos_cnum !== 1)) { - var match$16 = match$14.loc_end; - if (match$16.pos_fname === "" && !(match$16.pos_lnum !== 2 || match$16.pos_bol !== 1 || match$16.pos_cnum !== 9 || match$14.loc_ghost || match$12.type_attributes || match$5.typ_cstrs)) { - var match$17 = match$5.typ_kind; - if (typeof match$17 === "number" && !(match$17 !== 0 || !(match$5.typ_private && match$5.typ_manifest === undefined))) { - var match$18 = match$5.typ_loc; - var match$19 = match$18.loc_start; - if (match$19.pos_fname === "" && !(match$19.pos_lnum !== 2 || match$19.pos_bol !== 1 || match$19.pos_cnum !== 1)) { - var match$20 = match$18.loc_end; - if (match$20.pos_fname === "" && !(match$20.pos_lnum !== 2 || match$20.pos_bol !== 1 || match$20.pos_cnum !== 9 || match$18.loc_ghost || match$5.typ_attributes || match$4.tl)) { - var match$21 = match$2.str_loc; - var match$22 = match$21.loc_start; - if (match$22.pos_fname === "" && !(match$22.pos_lnum !== 2 || match$22.pos_bol !== 1 || match$22.pos_cnum !== 1)) { - var match$23 = match$21.loc_end; - if (match$23.pos_fname === "" && !(match$23.pos_lnum !== 2 || match$23.pos_bol !== 1 || match$23.pos_cnum !== 9 || match$21.loc_ghost)) { - var match$24 = match$1.tl; - if (match$24) { - var match$25 = match$24.hd.str_desc; - if (match$25.TAG === /* Tstr_primitive */2) { - var match$26 = match$25._0; - var match$27 = match$26.val_id; - if (match$27.name === "~-") { - var match$28 = match$27.flags; - if (match$28 !== 0) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$29 = match$26.val_name; - if (match$29.txt === "~-") { - var match$30 = match$29.loc; - var match$31 = match$30.loc_start; - if (match$31.pos_fname === "" && !(match$31.pos_lnum !== 3 || match$31.pos_bol !== 10 || match$31.pos_cnum !== 19)) { - var match$32 = match$30.loc_end; - if (match$32.pos_fname === "" && !(match$32.pos_lnum !== 3 || match$32.pos_bol !== 10 || match$32.pos_cnum !== 25 || match$30.loc_ghost)) { - var match$33 = match$26.val_desc; - var match$34 = match$33.ctyp_desc; - if (typeof match$34 === "number" || !(match$34.TAG === /* Ttyp_arrow */1 && match$34._0 === "")) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$35 = match$34._1; - var match$36 = match$35.ctyp_desc; - if (typeof match$36 === "number" || match$36.TAG !== /* Ttyp_constr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$37 = match$36._0; - switch (match$37.TAG | 0) { - case /* Pident */0 : - var match$38 = match$37._0; - if (match$38.name === "int") { - var match$39 = match$38.flags; - if (match$39 !== 0) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$40 = match$36._1; - var match$41 = match$40.txt; - switch (match$41.TAG | 0) { - case /* Lident */0 : - if (match$41._0 === "int") { - var match$42 = match$40.loc; - var match$43 = match$42.loc_start; - if (match$43.pos_fname === "" && !(match$43.pos_lnum !== 3 || match$43.pos_bol !== 10 || match$43.pos_cnum !== 28)) { - var match$44 = match$42.loc_end; - if (match$44.pos_fname === "" && !(match$44.pos_lnum !== 3 || match$44.pos_bol !== 10 || match$44.pos_cnum !== 31 || match$42.loc_ghost || match$36._2)) { - var match$45 = match$35.ctyp_type; - var match$46 = match$45.desc; - if (typeof match$46 === "number" || match$46.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$47 = match$46._0; - switch (match$47.TAG | 0) { - case /* Pident */0 : - var match$48 = match$47._0; - if (match$48.name === "int") { - var match$49 = match$48.flags; - if (match$49 !== 0 || match$46._1) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$50 = match$46._2.contents; - if (typeof match$50 === "number") { - var match$51 = match$35.ctyp_loc; - var match$52 = match$51.loc_start; - if (match$52.pos_fname === "" && !(match$52.pos_lnum !== 3 || match$52.pos_bol !== 10 || match$52.pos_cnum !== 28)) { - var match$53 = match$51.loc_end; - if (match$53.pos_fname === "" && !(match$53.pos_lnum !== 3 || match$53.pos_bol !== 10 || match$53.pos_cnum !== 31 || match$51.loc_ghost || match$35.ctyp_attributes)) { - var match$54 = match$34._2; - var match$55 = match$54.ctyp_desc; - if (typeof match$55 === "number" || match$55.TAG !== /* Ttyp_constr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$56 = match$55._0; - switch (match$56.TAG | 0) { - case /* Pident */0 : - var match$57 = match$56._0; - if (match$57.name === "int") { - var match$58 = match$57.flags; - if (match$58 !== 0) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$59 = match$55._1; - var match$60 = match$59.txt; - switch (match$60.TAG | 0) { - case /* Lident */0 : - if (match$60._0 === "int") { - var match$61 = match$59.loc; - var match$62 = match$61.loc_start; - if (match$62.pos_fname === "" && !(match$62.pos_lnum !== 3 || match$62.pos_bol !== 10 || match$62.pos_cnum !== 35)) { - var match$63 = match$61.loc_end; - if (match$63.pos_fname === "" && !(match$63.pos_lnum !== 3 || match$63.pos_bol !== 10 || match$63.pos_cnum !== 38 || match$61.loc_ghost || match$55._2)) { - var match$64 = match$54.ctyp_type; - var match$65 = match$64.desc; - if (typeof match$65 === "number" || match$65.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$66 = match$65._0; - switch (match$66.TAG | 0) { - case /* Pident */0 : - var match$67 = match$66._0; - if (match$67.name === "int") { - var match$68 = match$67.flags; - if (match$68 !== 0 || match$65._1) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$69 = match$65._2.contents; - if (typeof match$69 === "number") { - var match$70 = match$54.ctyp_loc; - var match$71 = match$70.loc_start; - if (match$71.pos_fname === "" && !(match$71.pos_lnum !== 3 || match$71.pos_bol !== 10 || match$71.pos_cnum !== 35)) { - var match$72 = match$70.loc_end; - if (match$72.pos_fname === "" && !(match$72.pos_lnum !== 3 || match$72.pos_bol !== 10 || match$72.pos_cnum !== 38 || match$70.loc_ghost || match$54.ctyp_attributes)) { - var match$73 = match$33.ctyp_type; - var match$74 = match$73.desc; - if (typeof match$74 === "number" || !(match$74.TAG === /* Tarrow */1 && match$74._0 === "")) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$75 = match$74._1.desc; - if (typeof match$75 === "number" || match$75.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$76 = match$75._0; - switch (match$76.TAG | 0) { - case /* Pident */0 : - var match$77 = match$76._0; - if (match$77.name === "int") { - var match$78 = match$77.flags; - if (match$78 !== 0 || match$75._1) { + var match$13 = match$12.type_loc; + var match$14 = match$13.loc_start; + if (match$14.pos_fname === "" && !(match$14.pos_lnum !== 2 || match$14.pos_bol !== 1 || match$14.pos_cnum !== 1)) { + var match$15 = match$13.loc_end; + if (match$15.pos_fname === "" && !(match$15.pos_lnum !== 2 || match$15.pos_bol !== 1 || match$15.pos_cnum !== 9 || match$13.loc_ghost || match$12.type_attributes || match$5.typ_cstrs || !(match$5.typ_kind === 0 && match$5.typ_private && match$5.typ_manifest === undefined))) { + var match$16 = match$5.typ_loc; + var match$17 = match$16.loc_start; + if (match$17.pos_fname === "" && !(match$17.pos_lnum !== 2 || match$17.pos_bol !== 1 || match$17.pos_cnum !== 1)) { + var match$18 = match$16.loc_end; + if (match$18.pos_fname === "" && !(match$18.pos_lnum !== 2 || match$18.pos_bol !== 1 || match$18.pos_cnum !== 9 || match$16.loc_ghost || match$5.typ_attributes || match$4.tl)) { + var match$19 = match$2.str_loc; + var match$20 = match$19.loc_start; + if (match$20.pos_fname === "" && !(match$20.pos_lnum !== 2 || match$20.pos_bol !== 1 || match$20.pos_cnum !== 1)) { + var match$21 = match$19.loc_end; + if (match$21.pos_fname === "" && !(match$21.pos_lnum !== 2 || match$21.pos_bol !== 1 || match$21.pos_cnum !== 9 || match$19.loc_ghost)) { + var match$22 = match$1.tl; + if (match$22) { + var match$23 = match$22.hd.str_desc; + if (match$23.TAG === /* Tstr_primitive */2) { + var match$24 = match$23._0; + var match$25 = match$24.val_id; + if (match$25.name === "~-") { + var match$26 = match$25.flags; + if (match$26 !== 0) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$27 = match$24.val_name; + if (match$27.txt === "~-") { + var match$28 = match$27.loc; + var match$29 = match$28.loc_start; + if (match$29.pos_fname === "" && !(match$29.pos_lnum !== 3 || match$29.pos_bol !== 10 || match$29.pos_cnum !== 19)) { + var match$30 = match$28.loc_end; + if (match$30.pos_fname === "" && !(match$30.pos_lnum !== 3 || match$30.pos_bol !== 10 || match$30.pos_cnum !== 25 || match$28.loc_ghost)) { + var match$31 = match$24.val_desc; + var match$32 = match$31.ctyp_desc; + if (typeof match$32 === "number" || !(match$32.TAG === /* Ttyp_arrow */1 && match$32._0 === "")) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$33 = match$32._1; + var match$34 = match$33.ctyp_desc; + if (typeof match$34 === "number" || match$34.TAG !== /* Ttyp_constr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$35 = match$34._0; + switch (match$35.TAG | 0) { + case /* Pident */0 : + var match$36 = match$35._0; + if (match$36.name === "int") { + var match$37 = match$36.flags; + if (match$37 !== 0) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$38 = match$34._1; + var match$39 = match$38.txt; + switch (match$39.TAG | 0) { + case /* Lident */0 : + if (match$39._0 === "int") { + var match$40 = match$38.loc; + var match$41 = match$40.loc_start; + if (match$41.pos_fname === "" && !(match$41.pos_lnum !== 3 || match$41.pos_bol !== 10 || match$41.pos_cnum !== 28)) { + var match$42 = match$40.loc_end; + if (match$42.pos_fname === "" && !(match$42.pos_lnum !== 3 || match$42.pos_bol !== 10 || match$42.pos_cnum !== 31 || match$40.loc_ghost || match$34._2)) { + var match$43 = match$33.ctyp_type; + var match$44 = match$43.desc; + if (typeof match$44 === "number" || match$44.TAG !== /* Tconstr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$45 = match$44._0; + switch (match$45.TAG | 0) { + case /* Pident */0 : + var match$46 = match$45._0; + if (match$46.name === "int") { + var match$47 = match$46.flags; + if (match$47 !== 0 || match$44._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$48 = match$44._2.contents; + if (typeof match$48 === "number") { + var match$49 = match$33.ctyp_loc; + var match$50 = match$49.loc_start; + if (match$50.pos_fname === "" && !(match$50.pos_lnum !== 3 || match$50.pos_bol !== 10 || match$50.pos_cnum !== 28)) { + var match$51 = match$49.loc_end; + if (match$51.pos_fname === "" && !(match$51.pos_lnum !== 3 || match$51.pos_bol !== 10 || match$51.pos_cnum !== 31 || match$49.loc_ghost || match$33.ctyp_attributes)) { + var match$52 = match$32._2; + var match$53 = match$52.ctyp_desc; + if (typeof match$53 === "number" || match$53.TAG !== /* Ttyp_constr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$54 = match$53._0; + switch (match$54.TAG | 0) { + case /* Pident */0 : + var match$55 = match$54._0; + if (match$55.name === "int") { + var match$56 = match$55.flags; + if (match$56 !== 0) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$57 = match$53._1; + var match$58 = match$57.txt; + switch (match$58.TAG | 0) { + case /* Lident */0 : + if (match$58._0 === "int") { + var match$59 = match$57.loc; + var match$60 = match$59.loc_start; + if (match$60.pos_fname === "" && !(match$60.pos_lnum !== 3 || match$60.pos_bol !== 10 || match$60.pos_cnum !== 35)) { + var match$61 = match$59.loc_end; + if (match$61.pos_fname === "" && !(match$61.pos_lnum !== 3 || match$61.pos_bol !== 10 || match$61.pos_cnum !== 38 || match$59.loc_ghost || match$53._2)) { + var match$62 = match$52.ctyp_type; + var match$63 = match$62.desc; + if (typeof match$63 === "number" || match$63.TAG !== /* Tconstr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$64 = match$63._0; + switch (match$64.TAG | 0) { + case /* Pident */0 : + var match$65 = match$64._0; + if (match$65.name === "int") { + var match$66 = match$65.flags; + if (match$66 !== 0 || match$63._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$67 = match$63._2.contents; + if (typeof match$67 === "number") { + var match$68 = match$52.ctyp_loc; + var match$69 = match$68.loc_start; + if (match$69.pos_fname === "" && !(match$69.pos_lnum !== 3 || match$69.pos_bol !== 10 || match$69.pos_cnum !== 35)) { + var match$70 = match$68.loc_end; + if (match$70.pos_fname === "" && !(match$70.pos_lnum !== 3 || match$70.pos_bol !== 10 || match$70.pos_cnum !== 38 || match$68.loc_ghost || match$52.ctyp_attributes)) { + var match$71 = match$31.ctyp_type; + var match$72 = match$71.desc; + if (typeof match$72 === "number" || !(match$72.TAG === /* Tarrow */1 && match$72._0 === "")) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$73 = match$72._1.desc; + if (typeof match$73 === "number" || match$73.TAG !== /* Tconstr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$74 = match$73._0; + switch (match$74.TAG | 0) { + case /* Pident */0 : + var match$75 = match$74._0; + if (match$75.name === "int") { + var match$76 = match$75.flags; + if (match$76 !== 0 || match$73._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$77 = match$73._2.contents; + if (typeof match$77 === "number") { + var match$78 = match$72._2.desc; + if (typeof match$78 === "number" || match$78.TAG !== /* Tconstr */3) { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } else { - var match$79 = match$75._2.contents; - if (typeof match$79 === "number") { - var match$80 = match$74._2.desc; - if (typeof match$80 === "number" || match$80.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$81 = match$80._0; - switch (match$81.TAG | 0) { - case /* Pident */0 : - var match$82 = match$81._0; - if (match$82.name === "int") { - var match$83 = match$82.flags; - if (match$83 !== 0 || match$80._1) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$84 = match$80._2.contents; - if (typeof match$84 === "number") { - var match$85 = match$74._3; - if (typeof match$85 === "number" && match$85 === 0) { - var match$86 = match$33.ctyp_loc; - var match$87 = match$86.loc_start; - if (match$87.pos_fname === "" && !(match$87.pos_lnum !== 3 || match$87.pos_bol !== 10 || match$87.pos_cnum !== 28)) { - var match$88 = match$86.loc_end; - if (match$88.pos_fname === "" && !(match$88.pos_lnum !== 3 || match$88.pos_bol !== 10 || match$88.pos_cnum !== 38 || match$86.loc_ghost || match$33.ctyp_attributes)) { - var match$89 = match$26.val_val; - var match$90 = match$89.val_type.desc; - if (typeof match$90 === "number" || !(match$90.TAG === /* Tarrow */1 && match$90._0 === "")) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$91 = match$90._1.desc; - if (typeof match$91 === "number" || match$91.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$92 = match$91._0; - switch (match$92.TAG | 0) { - case /* Pident */0 : - var match$93 = match$92._0; - if (match$93.name === "int") { - var match$94 = match$93.flags; - if (match$94 !== 0 || match$91._1) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$95 = match$91._2.contents; - if (typeof match$95 === "number") { - var match$96 = match$90._2.desc; - if (typeof match$96 === "number" || match$96.TAG !== /* Tconstr */3) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$97 = match$96._0; - switch (match$97.TAG | 0) { - case /* Pident */0 : - var match$98 = match$97._0; - if (match$98.name === "int") { - var match$99 = match$98.flags; - if (match$99 !== 0 || match$96._1) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$100 = match$96._2.contents; - if (typeof match$100 === "number") { - var match$101 = match$90._3; - if (typeof match$101 === "number" && match$101 === 0) { - var match$102 = match$89.val_kind; - if (typeof match$102 === "number" || match$102.TAG !== /* Val_prim */0) { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } else { - var match$103 = match$102._0; - if (match$103.prim_name === "%negint" && !(match$103.prim_arity !== 1 || !(match$103.prim_alloc && match$103.prim_native_name === "" && !match$103.prim_native_float))) { - var match$104 = match$89.val_loc; - var match$105 = match$104.loc_start; - if (match$105.pos_fname === "" && !(match$105.pos_lnum !== 3 || match$105.pos_bol !== 10 || match$105.pos_cnum !== 10)) { - var match$106 = match$104.loc_end; - if (match$106.pos_fname === "" && !(match$106.pos_lnum !== 3 || match$106.pos_bol !== 10 || match$106.pos_cnum !== 50 || match$104.loc_ghost || match$89.val_attributes)) { - eq("File \"ocaml_typedtree_test.ml\", line 52275, characters 14-21", true, true); - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } - } + var match$79 = match$78._0; + switch (match$79.TAG | 0) { + case /* Pident */0 : + var match$80 = match$79._0; + if (match$80.name === "int") { + var match$81 = match$80.flags; + if (match$81 !== 0 || match$78._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$82 = match$78._2.contents; + if (typeof match$82 === "number" && match$72._3 === 0) { + var match$83 = match$31.ctyp_loc; + var match$84 = match$83.loc_start; + if (match$84.pos_fname === "" && !(match$84.pos_lnum !== 3 || match$84.pos_bol !== 10 || match$84.pos_cnum !== 28)) { + var match$85 = match$83.loc_end; + if (match$85.pos_fname === "" && !(match$85.pos_lnum !== 3 || match$85.pos_bol !== 10 || match$85.pos_cnum !== 38 || match$83.loc_ghost || match$31.ctyp_attributes)) { + var match$86 = match$24.val_val; + var match$87 = match$86.val_type.desc; + if (typeof match$87 === "number" || !(match$87.TAG === /* Tarrow */1 && match$87._0 === "")) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$88 = match$87._1.desc; + if (typeof match$88 === "number" || match$88.TAG !== /* Tconstr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$89 = match$88._0; + switch (match$89.TAG | 0) { + case /* Pident */0 : + var match$90 = match$89._0; + if (match$90.name === "int") { + var match$91 = match$90.flags; + if (match$91 !== 0 || match$88._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$92 = match$88._2.contents; + if (typeof match$92 === "number") { + var match$93 = match$87._2.desc; + if (typeof match$93 === "number" || match$93.TAG !== /* Tconstr */3) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$94 = match$93._0; + switch (match$94.TAG | 0) { + case /* Pident */0 : + var match$95 = match$94._0; + if (match$95.name === "int") { + var match$96 = match$95.flags; + if (match$96 !== 0 || match$93._1) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$97 = match$93._2.contents; + if (typeof match$97 === "number" && match$87._3 === 0) { + var match$98 = match$86.val_kind; + if (typeof match$98 === "number" || match$98.TAG !== /* Val_prim */0) { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } else { + var match$99 = match$98._0; + if (match$99.prim_name === "%negint" && !(match$99.prim_arity !== 1 || !(match$99.prim_alloc && match$99.prim_native_name === "" && !match$99.prim_native_float))) { + var match$100 = match$86.val_loc; + var match$101 = match$100.loc_start; + if (match$101.pos_fname === "" && !(match$101.pos_lnum !== 3 || match$101.pos_bol !== 10 || match$101.pos_cnum !== 10)) { + var match$102 = match$100.loc_end; + if (match$102.pos_fname === "" && !(match$102.pos_lnum !== 3 || match$102.pos_bol !== 10 || match$102.pos_cnum !== 50 || match$100.loc_ghost || match$86.val_attributes)) { + eq("File \"ocaml_typedtree_test.ml\", line 52275, characters 14-21", true, true); } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : + } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - + } + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : + } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - + } + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Ldot */1 : - case /* Lapply */2 : + } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Ldot */1 : + case /* Lapply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - break; - case /* Ldot */1 : - case /* Lapply */2 : + } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Ldot */1 : + case /* Lapply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - break; - case /* Pdot */1 : - case /* Papply */2 : - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); - break; - - } - } + } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); + break; + } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } + } else { + eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } - } else { - eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); } } else { eq("File \"ocaml_typedtree_test.ml\", line 52276, characters 12-19", true, false); diff --git a/jscomp/test/parser_api.js b/jscomp/test/parser_api.js index b446e90970..6931dd8029 100644 --- a/jscomp/test/parser_api.js +++ b/jscomp/test/parser_api.js @@ -14497,11 +14497,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_and_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 0) { - push(e); - return v; - } + if (e === 0) { var calc$1 = calc && v; var b = parse_and_aux(calc$1, parse_relation(calc$1)); if (v) { @@ -14523,15 +14519,7 @@ function directive_parse(token_with_comments, lexbuf) { case /* LPAREN */54 : var v = parse_or_aux(calc, parse_and_aux(calc, parse_relation(calc))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 81) { - throw { - RE_EXN_ID: $$Error$2, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 81) { return v; } throw { @@ -14667,11 +14655,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var parse_or_aux = function (calc, v) { var e = token(undefined); - if (typeof e === "number") { - if (e !== 8) { - push(e); - return v; - } + if (e === 8) { var calc$1 = calc && !v; var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); if (v) { @@ -14685,15 +14669,7 @@ function directive_parse(token_with_comments, lexbuf) { }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); - if (typeof match === "number") { - if (match !== 88) { - throw { - RE_EXN_ID: $$Error$2, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; - } + if (match === 88) { return v; } throw { @@ -16108,13 +16084,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === $$Error$2) { - var match$1 = exn._1; - if (typeof match$1 === "number") { - if (match$1 !== 0) { - throw exn; - } - var match$2 = comment_start_loc.contents; - if (match$2) { + if (exn._1 === 0) { + var match$1 = comment_start_loc.contents; + if (match$1) { var start = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -16124,7 +16096,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start, _1: exn._2 }, - _2: match$2.hd, + _2: match$1.hd, Error: new Error() }; } @@ -16158,13 +16130,9 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.RE_EXN_ID === $$Error$2) { - var match$3 = exn$1._1; - if (typeof match$3 === "number") { - if (match$3 !== 0) { - throw exn$1; - } - var match$4 = comment_start_loc.contents; - if (match$4) { + if (exn$1._1 === 0) { + var match$2 = comment_start_loc.contents; + if (match$2) { var start$1 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -16174,7 +16142,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { _0: start$1, _1: exn$1._2 }, - _2: match$4.hd, + _2: match$2.hd, Error: new Error() }; } @@ -16204,8 +16172,8 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { ___ocaml_lex_state = 132; continue ; case 10 : - var match$5 = comment_start_loc.contents; - if (match$5) { + var match$3 = comment_start_loc.contents; + if (match$3) { var start$2 = List.hd(List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; throw { @@ -16214,7 +16182,7 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { TAG: /* Unterminated_comment */2, _0: start$2 }, - _2: match$5.hd, + _2: match$3.hd, Error: new Error() }; } diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 54fe9a2e98..3f7a249ca0 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -1084,9 +1084,6 @@ function compute_update_sequences(all_tickers) { List.fold_left((function (counter, ticker) { var loop = function (counter, ticker) { var rank = ticker.rank; - if (typeof rank !== "number") { - return counter; - } if (rank !== 0) { return counter; } diff --git a/jscomp/test/variant.js b/jscomp/test/variant.js index 82c82cdc69..681f493f77 100644 --- a/jscomp/test/variant.js +++ b/jscomp/test/variant.js @@ -26,7 +26,7 @@ function foo(n) { } function fooA1(param) { - if (typeof param === "number" && param === 0) { + if (param === 0) { return 1; } else { return 42; diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 0af1f973a7..af519408f0 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -96627,7 +96627,11 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t = default () let not_ loc x : t = - prim ~primitive:Pnot ~args:[x] loc + match x with + | Lprim ({primitive = Pintcomp Cneq } as prim)-> + Lprim {prim with primitive = Pintcomp Ceq} + | _ -> + prim ~primitive:Pnot ~args:[x] loc let has_boolean_type (x : t) = @@ -96720,6 +96724,24 @@ let if_ (a : t) (b : t) (c : t) : t = { body with sw_failaction = Some b; sw_consts_full = false; }) | _ -> Lifthenelse(a,b,c) end + | Lprim{primitive = Pisint; args = [Lvar i];_} + -> + begin match b with + | Lifthenelse(Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} , _, b_f) + when Ident.same i j && eq_approx b_f c -> + b + | Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} + when Ident.same i j && eq_approx false_ c -> b + | Lifthenelse(Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _]} as b_pred) , b_t, b_f) + when Ident.same i j && eq_approx b_t c -> + Lifthenelse(Lprim{b_pred with primitive = Pintcomp Ceq}, b_f, b_t) + | Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _] as args ; loc} ) + | Lprim( + {primitive = Pnot ; args = [Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _] as args; loc}]}) + when Ident.same i j && eq_approx true_ c + -> Lprim{primitive = Pintcomp Ceq; args; loc} + | _ -> Lifthenelse(a,b,c) + end | _ -> Lifthenelse (a,b,c)) diff --git a/lib/4.06.1/unstable/js_refmt_compiler.ml b/lib/4.06.1/unstable/js_refmt_compiler.ml index d2d8c3ecc3..66bd49d8cc 100644 --- a/lib/4.06.1/unstable/js_refmt_compiler.ml +++ b/lib/4.06.1/unstable/js_refmt_compiler.ml @@ -96627,7 +96627,11 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t = default () let not_ loc x : t = - prim ~primitive:Pnot ~args:[x] loc + match x with + | Lprim ({primitive = Pintcomp Cneq } as prim)-> + Lprim {prim with primitive = Pintcomp Ceq} + | _ -> + prim ~primitive:Pnot ~args:[x] loc let has_boolean_type (x : t) = @@ -96720,6 +96724,24 @@ let if_ (a : t) (b : t) (c : t) : t = { body with sw_failaction = Some b; sw_consts_full = false; }) | _ -> Lifthenelse(a,b,c) end + | Lprim{primitive = Pisint; args = [Lvar i];_} + -> + begin match b with + | Lifthenelse(Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} , _, b_f) + when Ident.same i j && eq_approx b_f c -> + b + | Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} + when Ident.same i j && eq_approx false_ c -> b + | Lifthenelse(Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _]} as b_pred) , b_t, b_f) + when Ident.same i j && eq_approx b_t c -> + Lifthenelse(Lprim{b_pred with primitive = Pintcomp Ceq}, b_f, b_t) + | Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _] as args ; loc} ) + | Lprim( + {primitive = Pnot ; args = [Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _] as args; loc}]}) + when Ident.same i j && eq_approx true_ c + -> Lprim{primitive = Pintcomp Ceq; args; loc} + | _ -> Lifthenelse(a,b,c) + end | _ -> Lifthenelse (a,b,c)) diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index 8efb087b8b..d329a78a80 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -372120,7 +372120,11 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t = default () let not_ loc x : t = - prim ~primitive:Pnot ~args:[x] loc + match x with + | Lprim ({primitive = Pintcomp Cneq } as prim)-> + Lprim {prim with primitive = Pintcomp Ceq} + | _ -> + prim ~primitive:Pnot ~args:[x] loc let has_boolean_type (x : t) = @@ -372213,6 +372217,24 @@ let if_ (a : t) (b : t) (c : t) : t = { body with sw_failaction = Some b; sw_consts_full = false; }) | _ -> Lifthenelse(a,b,c) end + | Lprim{primitive = Pisint; args = [Lvar i];_} + -> + begin match b with + | Lifthenelse(Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} , _, b_f) + when Ident.same i j && eq_approx b_f c -> + b + | Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _]} + when Ident.same i j && eq_approx false_ c -> b + | Lifthenelse(Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _]} as b_pred) , b_t, b_f) + when Ident.same i j && eq_approx b_t c -> + Lifthenelse(Lprim{b_pred with primitive = Pintcomp Ceq}, b_f, b_t) + | Lprim({primitive = Pintcomp Cneq ; args = [Lvar j; Lconst _] as args ; loc} ) + | Lprim( + {primitive = Pnot ; args = [Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _] as args; loc}]}) + when Ident.same i j && eq_approx true_ c + -> Lprim{primitive = Pintcomp Ceq; args; loc} + | _ -> Lifthenelse(a,b,c) + end | _ -> Lifthenelse (a,b,c)) @@ -435941,7 +435963,7 @@ let setup_runtime_path path = let _path = Filename.dirname u0 in let rescript = Filename.basename u0 in (match rescript.[0] with - | '@' -> + | '@' -> (* scoped package *) Bs_version.package_name := rescript ^ "/" ^ std; | _ -> Bs_version.package_name := std | exception _ -> diff --git a/lib/es6/camlinternalFormat.mjs b/lib/es6/camlinternalFormat.mjs index e76ebae4db..48ef88a325 100644 --- a/lib/es6/camlinternalFormat.mjs +++ b/lib/es6/camlinternalFormat.mjs @@ -5408,36 +5408,36 @@ function fmt_ebb_of_string(legacy_behavior, str) { var parse_conv = function (padprec) { return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, prec, padprec, Caml_string.get(str, str_ind)); }; - if (typeof pad !== "number") { - return parse_conv(pad); - } - if (typeof prec === "number" && prec === 0) { - return parse_conv(/* No_padding */0); - } - if (minus) { - if (typeof prec === "number") { + if (typeof pad === "number") { + if (prec === 0) { + return parse_conv(/* No_padding */0); + } else if (minus) { + if (typeof prec === "number") { + return parse_conv({ + TAG: /* Arg_padding */1, + _0: /* Left */0 + }); + } else { + return parse_conv({ + TAG: /* Lit_padding */0, + _0: /* Left */0, + _1: prec._0 + }); + } + } else if (typeof prec === "number") { return parse_conv({ TAG: /* Arg_padding */1, - _0: /* Left */0 + _0: /* Right */1 }); } else { return parse_conv({ TAG: /* Lit_padding */0, - _0: /* Left */0, + _0: /* Right */1, _1: prec._0 }); } - } else if (typeof prec === "number") { - return parse_conv({ - TAG: /* Arg_padding */1, - _0: /* Right */1 - }); } else { - return parse_conv({ - TAG: /* Lit_padding */0, - _0: /* Right */1, - _1: prec._0 - }); + return parse_conv(pad); } }; var parse_flags = function (pct_ind, str_ind, end_ind, ign) { @@ -5601,10 +5601,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { var get_int_pad = function (param) { pad_used.contents = true; prec_used.contents = true; - if (typeof prec === "number" && prec === 0) { + if (prec === 0) { return pad; - } - if (typeof pad === "number") { + } else if (typeof pad === "number") { return /* No_padding */0; } else if (pad.TAG === /* Lit_padding */0) { if (pad._0 >= 2) { diff --git a/lib/js/camlinternalFormat.js b/lib/js/camlinternalFormat.js index f76f7fe51d..ecc10d1b6a 100644 --- a/lib/js/camlinternalFormat.js +++ b/lib/js/camlinternalFormat.js @@ -5408,36 +5408,36 @@ function fmt_ebb_of_string(legacy_behavior, str) { var parse_conv = function (padprec) { return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, prec, padprec, Caml_string.get(str, str_ind)); }; - if (typeof pad !== "number") { - return parse_conv(pad); - } - if (typeof prec === "number" && prec === 0) { - return parse_conv(/* No_padding */0); - } - if (minus) { - if (typeof prec === "number") { + if (typeof pad === "number") { + if (prec === 0) { + return parse_conv(/* No_padding */0); + } else if (minus) { + if (typeof prec === "number") { + return parse_conv({ + TAG: /* Arg_padding */1, + _0: /* Left */0 + }); + } else { + return parse_conv({ + TAG: /* Lit_padding */0, + _0: /* Left */0, + _1: prec._0 + }); + } + } else if (typeof prec === "number") { return parse_conv({ TAG: /* Arg_padding */1, - _0: /* Left */0 + _0: /* Right */1 }); } else { return parse_conv({ TAG: /* Lit_padding */0, - _0: /* Left */0, + _0: /* Right */1, _1: prec._0 }); } - } else if (typeof prec === "number") { - return parse_conv({ - TAG: /* Arg_padding */1, - _0: /* Right */1 - }); } else { - return parse_conv({ - TAG: /* Lit_padding */0, - _0: /* Right */1, - _1: prec._0 - }); + return parse_conv(pad); } }; var parse_flags = function (pct_ind, str_ind, end_ind, ign) { @@ -5601,10 +5601,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { var get_int_pad = function (param) { pad_used.contents = true; prec_used.contents = true; - if (typeof prec === "number" && prec === 0) { + if (prec === 0) { return pad; - } - if (typeof pad === "number") { + } else if (typeof pad === "number") { return /* No_padding */0; } else if (pad.TAG === /* Lit_padding */0) { if (pad._0 >= 2) {