Merge: typing: get_method refactoring
authorJean Privat <jean@pryen.org>
Fri, 12 Jul 2019 19:53:15 +0000 (15:53 -0400)
committerJean Privat <jean@pryen.org>
Fri, 12 Jul 2019 19:53:15 +0000 (15:53 -0400)
Split the get_method to three different entry points. These new entry points make it possible to adapt the treatment to the actual context. This avoids creating callsites manually and in the same time do the verification if the researched method exist (display an error if not exist)

Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>

Pull-Request: #2760
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit
tests/nit.args
tests/nitc.args
tests/niti.skip
tests/nitvm.skip
tests/sav/nit_args9.res [new file with mode: 0644]
tests/sav/nitc_args12.res [new file with mode: 0644]

index e786374..f04c86d 100644 (file)
@@ -196,7 +196,7 @@ class MakefileToolchain
                var time1 = get_time
                self.toolcontext.info("*** END WRITING C: {time1-time0} ***", 2)
 
-               if not toolcontext.check_errors then return
+               toolcontext.check_errors
 
                # Execute the Makefile
 
index ba1a276..5eff78e 100644 (file)
@@ -6,3 +6,4 @@ base_simple3.nit
 -n -e 'print line' test_prog/README.md test_prog/test_prog.nit
 test_ffi_c_interpreter.nit
 -
+--keep-going test_keep_going.nit --run --dir out/
index b68b2f2..d590e01 100644 (file)
@@ -9,3 +9,4 @@ test_define.nit -D text=hello -D num=42 -D flag --dir out/ ; out/test_define
 --log --log-dir $WRITE test_prog -o out/test_prog.bin
 test_define.nit --semi-global -D text=hello -D num=42 -D flag --dir out/ ; out/test_define
 --run ../examples/print_arguments.nit 1 2 3 --dir out/
+--keep-going test_keep_going.nit --run --dir out/
index 0d24e60..4beb4fb 100644 (file)
@@ -5,6 +5,7 @@ nit_args4
 nit_args5
 nit_args6
 nit_args8
+nit_args9
 nitvm_args1
 nitvm_args3
 nitin
index 697b17e..097ca87 100644 (file)
@@ -5,6 +5,7 @@ nit_args4
 nit_args5
 nit_args6
 nit_args8
+nit_args9
 nitvm_args1
 nitvm_args3
 nitin
diff --git a/tests/sav/nit_args9.res b/tests/sav/nit_args9.res
new file mode 100644 (file)
index 0000000..1a3a40c
--- /dev/null
@@ -0,0 +1,25 @@
+\e[0;33mtest_keep_going.nit:15,11--14\e[0m: Error: class `Fail` not found in module `test_keep_going`.
+       fun plop: \e[1;31mFail\e[0m
+                 ^
+\e[0;33mtest_keep_going.nit:40,2--11\e[0m: Error: unreachable statement.
+               \e[1;31m999.output\e[0m
+               ^
+\e[0;33mtest_keep_going.nit:26,2--5\e[0m: Error: method or variable `fail` unknown in `Sys`.
+               \e[1;31mfail\e[0m
+               ^
+\e[0;33mtest_keep_going.nit:30,14--17\e[0m: Error: class `Fail` not found in module `test_keep_going`.
+               var x = new \e[1;31mFail\e[0m
+                           ^
+\e[0;33mtest_keep_going.nit:35,5\e[0m: Type Error: expected `Bool`, got `Int`.
+               if \e[1;31m1\e[0m then abort
+                  ^
+\e[0;33mtest_keep_going.nit:44,18--21\e[0m: Error: method `fail` does not exists in `Sys`.
+               var a = new Sys.\e[1;31mfail\e[0m
+                               ^
+1
+2
+3
+4
+5
+6
+7
diff --git a/tests/sav/nitc_args12.res b/tests/sav/nitc_args12.res
new file mode 100644 (file)
index 0000000..4181eb7
--- /dev/null
@@ -0,0 +1,26 @@
+\e[0;33mtest_keep_going.nit:15,11--14\e[0m: Error: class `Fail` not found in module `test_keep_going`.
+       fun plop: \e[1;31mFail\e[0m
+                 ^
+\e[0;33mtest_keep_going.nit:40,2--11\e[0m: Error: unreachable statement.
+               \e[1;31m999.output\e[0m
+               ^
+\e[0;33mtest_keep_going.nit:26,2--5\e[0m: Error: method or variable `fail` unknown in `Sys`.
+               \e[1;31mfail\e[0m
+               ^
+\e[0;33mtest_keep_going.nit:30,14--17\e[0m: Error: class `Fail` not found in module `test_keep_going`.
+               var x = new \e[1;31mFail\e[0m
+                           ^
+\e[0;33mtest_keep_going.nit:35,5\e[0m: Type Error: expected `Bool`, got `Int`.
+               if \e[1;31m1\e[0m then abort
+                  ^
+\e[0;33mtest_keep_going.nit:44,18--21\e[0m: Error: method `fail` does not exists in `Sys`.
+               var a = new Sys.\e[1;31mfail\e[0m
+                               ^
+Errors: 6. Warnings: 0.
+1
+2
+3
+4
+5
+6
+7