diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/syntax/type_of.ml | 31 | 
1 files changed, 16 insertions, 15 deletions
| diff --git a/lib/syntax/type_of.ml b/lib/syntax/type_of.ml index 410a0b1..b991e43 100644 --- a/lib/syntax/type_of.ml +++ b/lib/syntax/type_of.ml @@ -55,12 +55,12 @@ module Helper = struct        (* Strict equality for this ones, always true *)        | String, Variable String        | String, Raw String -      | String, Raw NumericString        | String, Variable NumericString +      | String, Raw NumericString        | Integer, Variable Integer        | Integer, Raw Integer -      | NumericString, Raw NumericString        | NumericString, Variable NumericString +      | NumericString, Raw NumericString        | Bool, Raw Bool        | Bool, Variable Bool        (* Also include the conversion between bool and integer *) @@ -71,9 +71,7 @@ module Helper = struct        | NumericString, Raw String        | NumericString, Variable String        | NumericString, Raw Integer -      | NumericString, Variable Integer -      (* A numeric type can be used at any place *) -      | String, Raw Integer -> +      | NumericString, Variable Integer ->            true        | Bool, Variable Integer when not strict -> true        | Bool, Raw Integer when not strict -> true @@ -81,9 +79,9 @@ module Helper = struct        | String, Raw Bool when not strict -> true        | String, Variable Bool when not strict -> true        | Integer, Variable String when not strict -> true -      (* Explicit rejected cases  *)        | Integer, Raw NumericString when not strict -> true -      | Integer, Raw String -> false +      (* Explicit rejected cases  *) +      | String, Raw Integer | Integer, Raw String -> false        | _, _ -> false      in      if equal then report @@ -341,23 +339,26 @@ module TypedExpression = struct          let report = Helper.compare_args pos expected types report in          ({ pos; empty = false }, report) -    | T.Eq | T.Neq -> +    | T.Eq | T.Neq | Lt | Gte | Lte | Gt ->          (* If the expression is '' or 0, we accept the comparaison as if              instead of raising a warning *)          if t1.empty || t2.empty then ({ pos; empty = false }, report)          else            let d = Helper.(Dynamic (DynType.t ())) in            let expected = [ d; d ] in +          (* Compare and report as error if the types are incompatible. If no +             error is reported, try in strict mode, and report as a warning. *)            let report = -            Helper.compare_args ~strict:true pos expected (List.rev types) -              report +            match +              Helper.compare_args ~level:Error pos expected (List.rev types) +                report +            with +            | [] -> +                Helper.compare_args ~strict:true pos expected (List.rev types) +                  report +            | report -> report            in            ({ pos; empty = false }, report) -    | Lt | Gte | Lte | Gt -> -        let d = Helper.(Dynamic (DynType.t ())) in -        let expected = [ d; d ] in -        let report = Helper.compare_args pos expected types report in -        ({ pos; empty = false }, report)      | T.Mod | T.Minus | T.Product | T.Div ->          (* Operation over number *)          let expected = Helper.[ Fixed Integer; Fixed Integer ] in | 
