|
@@ -190,16 +190,19 @@ module TypedExpression = struct
|
|
|
=
|
|
|
fun pos values type_of ->
|
|
|
ignore type_of;
|
|
|
- let init = ({ pos; empty = true }, []) in
|
|
|
- let result =
|
|
|
- List.fold_left values ~init ~f:(fun (_, report) -> function
|
|
|
+ let init = (true, []) in
|
|
|
+ let empty, report =
|
|
|
+ List.fold_left values ~init ~f:(fun (was_empty, report) -> function
|
|
|
| T.Text t ->
|
|
|
- let empty = String.equal t String.empty in
|
|
|
- ({ pos; empty }, report)
|
|
|
- | T.Expression t -> snd t)
|
|
|
+ let empty_text = String.equal t String.empty in
|
|
|
+ let empty = was_empty && empty_text in
|
|
|
+ (empty, report)
|
|
|
+ | T.Expression (_, t) ->
|
|
|
+ let empty = was_empty && (fst t).empty in
|
|
|
+ let report = List.rev_append (snd t) (snd init) in
|
|
|
+ (empty, report))
|
|
|
in
|
|
|
-
|
|
|
- result
|
|
|
+ ({ pos; empty }, report)
|
|
|
|
|
|
let function_ :
|
|
|
S.pos ->
|
|
@@ -334,23 +337,21 @@ module TypedExpression = struct
|
|
|
| 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 =
|
|
|
- match
|
|
|
- Helper.compare_args ~level:Error pos expected (List.rev types)
|
|
|
+ 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 =
|
|
|
+ match
|
|
|
+ Helper.compare_args ~level:Error pos expected (List.rev types)
|
|
|
+ report
|
|
|
+ with
|
|
|
+ | [] ->
|
|
|
+ Helper.compare_args ~strict:true 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)
|
|
|
+ | report -> 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
|
|
@@ -448,6 +449,7 @@ module Instruction = struct
|
|
|
let report' = Option.map snd variable.index |> Option.value ~default:[] in
|
|
|
|
|
|
let report = List.rev_append report' report in
|
|
|
+
|
|
|
match
|
|
|
( right_expression.empty,
|
|
|
op,
|