diff options
author | Chimrod <> | 2024-06-05 22:32:55 +0200 |
---|---|---|
committer | Chimrod <> | 2024-06-05 22:32:55 +0200 |
commit | 4535058e48fc8edc44be20b92a182279eb9e1569 (patch) | |
tree | 51d93109b32beaacfa7419d320dc776e1e8c704d /lib | |
parent | cb3b715053e5050201ca6074cf202033f07f50ec (diff) |
Typeof: Do not raise warning when assigning an integer in a string variable
Diffstat (limited to 'lib')
-rw-r--r-- | lib/syntax/type_of.ml | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/syntax/type_of.ml b/lib/syntax/type_of.ml index b991e43..d0437c9 100644 --- a/lib/syntax/type_of.ml +++ b/lib/syntax/type_of.ml @@ -454,9 +454,15 @@ 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 with - | true -> report - | false -> ( + match + ( right_expression.empty, + Get_type.get_type (Lazy.force right_expression.result) ) + with + | true, _ + (* It’s allowed to assign an integer in any kind of variable *) + | _, Get_type.(Integer) -> + report + | false, _ -> ( let var_type = Lazy.from_val (Get_type.ident variable) in let op1 = arg_of_repr var_type variable.pos in let op2 = arg_of_repr right_expression.result right_expression.pos in |