class C[E]
var x: E
redef fun to_s
do
if x != null then
return "x is {x.as(not null)}"
end
return "x is null"
end
end
var c1 = new C[nullable Object](null)
var c2 = new C[nullable Int](null)
c1.x = "test"
c2.x = 100
The global compiler will try to inline the message sending when c1.x = .... However, this produce type_test which is unreachable :
$ nitc failing_example.nit --global
nitc__temp.nitgg.1.c: In function ‘nitc__temp___core__Sys___main’:
nitc__temp.nitgg.1.c:7419:6: warning: statement will never be executed [-Wswitch-unreachable]
var2 = 1;
~~~~~^~~
nitc__temp.nitgg.1.c:7474:6: warning: statement will never be executed [-Wswitch-unreachable]
var7 = 1;
~~~~~^~~
nitc__temp.nitgg.1.c:7577:7: warning: statement will never be executed [-Wswitch-unreachable]
var23 = 1;
Here's the use case when compiling with
--global
:The global compiler will try to inline the message sending when
c1.x = ...
. However, this produce type_test which is unreachable :The generated C code :