compiler: runtime error (instead of noop) on dead/invalid code
authorJean Privat <jean@pryen.org>
Wed, 27 May 2015 20:05:41 +0000 (16:05 -0400)
committerJean Privat <jean@pryen.org>
Fri, 5 Jun 2015 19:05:33 +0000 (15:05 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit

index 8d3f7db..b69a049 100644 (file)
@@ -1637,8 +1637,9 @@ abstract class AbstractCompilerVisitor
                if nexpr == null then return
                if nexpr.mtype == null and not nexpr.is_typed then
                        # Untyped expression.
-                       # Might mean dead code
-                       # So just return
+                       # Might mean dead code or invalid code
+                       # so aborts
+                       add_abort("FATAL: bad statement executed.")
                        return
                end
 
@@ -1662,8 +1663,10 @@ abstract class AbstractCompilerVisitor
        do
                if nexpr.mtype == null then
                        # Untyped expression.
-                       # Might mean dead code
-                       # so return a placebo result
+                       # Might mean dead code or invalid code.
+                       # so aborts
+                       add_abort("FATAL: bad expression executed.")
+                       # and return a placebo result to please the C compiler
                        if mtype == null then mtype = compiler.mainmodule.object_type
                        return new_var(mtype)
                end