#1988 Nullability problems with facet

Jens Fri 3 Aug 2012

Problem 1

facet class Faa1 {
  const Obj obj

@Faa1{obj = null}
class Bar1 {}

class NullabilityProblem
  Void main() {
    fac := Bar1#.facet(Faa1#)

The above compiles without errors in 1.0.63. I think it should result in a:

'null' is not assignable to 'sys::Obj'

Instead it throws this in the main method:

sys::IOErr: Cannot make fan_test::Faa1: sys::FieldNotSetErr: fan_test::Faa1.obj [Line 1]ERROR: Cannot decode facet fan_test::Faa1: fan_test::Faa1{obj=null;}
sys::IOErr: ERROR: Cannot decode facet fan_test::Faa1: fan_test::Faa1{obj=null;}

	at fan.sys.IOErr.make(IOErr.java:31)
	at fan.sys.IOErr.make(IOErr.java:21)
	at fanx.serial.ObjDecoder.err(ObjDecoder.java:665)
	at fanx.serial.ObjDecoder.readComplex(ObjDecoder.java:249)
	at fanx.serial.ObjDecoder.readObj(ObjDecoder.java:146)
	at fanx.serial.ObjDecoder.readObj(ObjDecoder.java:55)
	at fanx.serial.ObjDecoder.decode(ObjDecoder.java:28)
	at fan.sys.Facets.decode(Facets.java:94)
	at fan.sys.Facets.get(Facets.java:78)
	at fan.sys.ClassType.facet(ClassType.java:217)
	at fan.sys.Type.facet(Type.java:303)
	at fan.fan_test.NullabilityProblem.main(NullabilityProblem.fan:33)

Problem 2

Also, I think this should compile:

facet class Faa2 {
  const Foo? foo

const class Foo{}

@Faa2{foo = null}
class Bar2 {}

but it gives an error:

Invalid type for facet field 'foo': expected 'some_pod::Foo?' not 'sys::Obj?'

Changing to either of these makes it compile:

@Faa2{foo = (Foo) null}
class Bar2 {}
facet class Faa2 {
  const Obj? foo;

brian Fri 3 Aug 2012

Promoted to ticket #1988 and assigned to brian

brian Wed 18 Oct 2017

Ticket resolved in 1.0.70

Login or Signup to reply.