toitlang/toit

insufficient type checks in constructors

floitsch opened this issue · 0 comments

The following program should fail dynamically.
Due to insufficient checks programs can segfault if the compiler uses the field's type.

class A:
  foo/int

  constructor .foo:

class B:
  a/A

  constructor map:
    a = map["foo"]
    print a is A  // Clearly this should be true.

  foo: return a.foo

main:
  b := B { "foo": "str" }
  print b.foo