@@ -336,22 +336,6 @@ let zero_float_lit : t =
336336let float_mod ?comment e1 e2 : J.expression =
337337 { comment; expression_desc = Bin (Mod , e1, e2) }
338338
339- let literal = function
340- | Ast_untagged_variants. String s -> str s ~delim: DStarJ
341- | Int i -> small_int i
342- | Float f -> float f
343- | Bool b -> bool b
344- | Null -> nil
345- | Undefined -> undefined
346- | Block IntType -> str " number"
347- | Block FloatType -> str " number"
348- | Block StringType -> str " string"
349- | Block Array -> str " Array" ~delim: DNoQuotes
350- | Block Object -> str " object"
351- | Block Unknown ->
352- (* TODO: clean up pattern mathing algo whih confuses literal with blocks *)
353- assert false
354-
355339let array_index ?comment (e0 : t ) (e1 : t ) : t =
356340 match (e0.expression_desc, e1.expression_desc) with
357341 | Array (l, _), Number (Int { i; _ })
@@ -776,7 +760,23 @@ let string_equal ?comment (e0 : t) (e1 : t) : t =
776760let is_type_number ?comment (e : t ) : t =
777761 string_equal ?comment (typeof e) (str " number" )
778762
779- let rec is_a_literal_case ~(literal_cases : Ast_untagged_variants.literal_type list ) ~block_cases (e :t ) : t =
763+ let tag_type = function
764+ | Ast_untagged_variants. String s -> str s ~delim: DStarJ
765+ | Int i -> small_int i
766+ | Float f -> float f
767+ | Bool b -> bool b
768+ | Null -> nil
769+ | Undefined -> undefined
770+ | Untagged IntType -> str " number"
771+ | Untagged FloatType -> str " number"
772+ | Untagged StringType -> str " string"
773+ | Untagged ArrayType -> str " Array" ~delim: DNoQuotes
774+ | Untagged ObjectType -> str " object"
775+ | Untagged UnknownType ->
776+ (* TODO: this should not happen *)
777+ assert false
778+
779+ let rec is_a_literal_case ~(literal_cases : Ast_untagged_variants.tag_type list ) ~block_cases (e :t ) : t =
780780 let literals_overlaps_with_string () =
781781 Ext_list. exists literal_cases (function
782782 | String _ -> true
@@ -793,24 +793,24 @@ let rec is_a_literal_case ~(literal_cases : Ast_untagged_variants.literal_type l
793793 let (!=) x y = bin NotEqEq x y in
794794 let (||) x y = bin Or x y in
795795 let (&&) x y = bin And x y in
796- let is_literal_case (l : Ast_untagged_variants.literal_type ) : t = e == (literal l ) in
797- let is_not_block_case (c :Ast_untagged_variants.block_type ) : t = match c with
796+ let is_literal_case (t : Ast_untagged_variants.tag_type ) : t = e == (tag_type t ) in
797+ let is_not_block_case (c : Ast_untagged_variants.block_type ) : t = match c with
798798 | StringType when literals_overlaps_with_string () = false (* No overlap *) ->
799799 (typeof e) != (str " string" )
800800 | IntType when literals_overlaps_with_number () = false ->
801801 (typeof e) != (str " number" )
802802 | FloatType when literals_overlaps_with_number () = false ->
803803 (typeof e) != (str " number" )
804- | Array ->
804+ | ArrayType ->
805805 not (is_array e)
806- | Object when literals_overlaps_with_object () = false ->
806+ | ObjectType when literals_overlaps_with_object () = false ->
807807 (typeof e) != (str " object" )
808- | Object (* overlap *) ->
808+ | ObjectType (* overlap *) ->
809809 e == nil || (typeof e) != (str " object" )
810810 | StringType (* overlap *)
811811 | IntType (* overlap *)
812812 | FloatType (* overlap *)
813- | Unknown ->
813+ | UnknownType ->
814814 (* We don't know the type of unknown, so we need to express:
815815 this is not one of the literals *)
816816 (match literal_cases with
0 commit comments