2 Commits 0f9f5d50bd ... 118f5fda2a

Author SHA1 Message Date
  Chimrod 118f5fda2a Report as a Warn error when an string is assigned in an Int variable 4 months ago
  Chimrod fcf05a8306 Also include the debugs messages in the exit code 4 months ago
3 changed files with 15 additions and 4 deletions
  1. 2 2
      bin/qsp_parser.ml
  2. 1 1
      lib/syntax/type_of.ml
  3. 12 1
      test/type_of.ml

+ 2 - 2
bin/qsp_parser.ml

@@ -153,7 +153,7 @@ let () =
   | 0, 0 ->
       print_endline "No errors found";
       exit 0
-  | _ ->
+  | _ -> (
       Printf.printf "Found %d error(s), %d warning(s)\n" !ctx.error_nb
         !ctx.warn_nb;
-      exit 1
+      match !ctx.debug_nb with 0 -> exit 0 | _ -> exit 1)

+ 1 - 1
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

+ 12 - 1
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;