diff options
author | Chimrod <> | 2024-01-14 12:12:28 +0100 |
---|---|---|
committer | Chimrod <> | 2024-01-14 12:23:21 +0100 |
commit | 60cb98b4a27ff0f59298646c835606d0a9a47ba3 (patch) | |
tree | c5e2cee95577d363039012fcb43af17da62a54e9 | |
parent | c6dbbaa9e11c34330315f614d922da8ede5824aa (diff) |
Report as a Warn error when an string is assigned in an Int variable
-rw-r--r-- | lib/syntax/type_of.ml | 2 | ||||
-rw-r--r-- | test/type_of.ml | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/syntax/type_of.ml b/lib/syntax/type_of.ml index b2776fc..4344a11 100644 --- a/lib/syntax/type_of.ml +++ b/lib/syntax/type_of.ml @@ -465,7 +465,7 @@ module Instruction = struct [ op1; op2 ] [] with | [] -> - Helper.compare_args ~strict:true ~level:Report.Debug pos expected + Helper.compare_args ~strict:true ~level:Report.Warn pos expected [ op1; op2 ] report | reports -> reports @ report) end diff --git a/test/type_of.ml b/test/type_of.ml index a73684a..bca7ea0 100644 --- a/test/type_of.ml +++ b/test/type_of.ml @@ -15,11 +15,21 @@ let type_mismatch () = }; ] +let type_mismatch2 () = + _test_instruction {|abc[''] = $Var|} + [ + { + level = Warn; + loc = _position; + message = "The type Integer is expected but got String"; + }; + ] + let type_conversion () = _test_instruction {|abc = '123'|} [ { - level = Debug; + level = Warn; loc = _position; message = "The type Integer is expected but got Integer as String"; }; @@ -54,6 +64,7 @@ let test = ( "Typechecking", [ Alcotest.test_case "Assign" `Quick type_mismatch; + Alcotest.test_case "Assign array" `Quick type_mismatch2; Alcotest.test_case "Conversion" `Quick type_conversion; Alcotest.test_case "Conversion'" `Quick type_conversion'; Alcotest.test_case "Comparaison" `Quick type_comparaison; |