nit icon indicating copy to clipboard operation
nit copied to clipboard

Missing cast when compiling safe call

Open Louis-Vincent opened this issue 4 years ago • 0 comments

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

Louis-Vincent avatar Nov 09 '19 19:11 Louis-Vincent