nitlang / nit

Nit language
http://nitlanguage.org
Apache License 2.0
238 stars 64 forks source link

Missing cast when compiling safe call #2804

Closed Louis-Vincent closed 1 week ago

Louis-Vincent commented 4 years ago

Here's the minimal code to reproduce the error :

class A
    var x: Int
end

class B
    var a: nullable A = null
end

var b = new B
var a = new A(10)

b.a = a
print "b.a.x: {b.a?.x or else "nothing"}"

Here's the compilation warning generated :

$ nitc error.nit
nitc__error.sep.1.c: In function ‘nitc__error___core__Sys___main’:
nitc__error.sep.1.c:109:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
 var14 = var13;

Finally, when we execute the compiled version, this print:

b.a.x: 

The integer isn't properly casted, it fails to produce the proper output