#2773 Compiling Const Lists and Maps

SlimerDude Sat 5 Oct 2019

const class Example {
    const NonConstClass[] oops  // this line compiles quite happily!
    new make(|This| f) { f(this) }

class NonConstClass { }

I notice the Fantom compiler lets you define const fields of Lists and Maps with non-const types.

I understand that the actual type is sys::List or sys::Map which may or may not be immutable, but I'd have thought the compiler would be able to inspect the defined parametrised type to make a judgement call.

Could this not be added?

Login or Signup to reply.