trill-lang / trill

A type safe, compiled language inspired by (and written in) Swift
MIT License
275 stars 15 forks source link

Allow printing custom types with their values #19

Closed segiddins closed 7 years ago

segiddins commented 7 years ago

this now works

indirect type Foo {
  let x: Int
  var y: Foo
  let z: String
}

type Bar {
  let x: Int
  let z: String
}

func fhdjsfhjskdhfjkds() {
  let x = 5 as Any
  println(x as Int)
}

func nooooo() {
  let x = Bar(x: 5, z: String(cString: "fdshfjkdshfksd")) as Any
  println(x)
}

func main() {
  nooooo()
  fhdjsfhjskdhfjkds()
  let x = ("a", 4) //as Any

  println(x)
  let anyX = x as Any

  let foo = Foo(x: 0, y:
      Foo(x: 6540, y: nil, z: String(cString: "fdshfjkdshfksd")),
    z: String(cString: "fdsfs"))

  println(((foo.y as Any) as Foo).x)
  println(foo)
}
harlanhaskins commented 7 years ago

Also you'll need to fix the conflicts

segiddins commented 7 years ago

Ugh this looks like a nasty rebase

harlanhaskins commented 7 years ago

😬 if you want I can take a spin at it

segiddins commented 7 years ago

Rebased