hylo-lang / hylo

The Hylo programming language
https://www.hylo-lang.org
Apache License 2.0
1.24k stars 59 forks source link

Overloading subscript on inout doesn't work #688

Open dabrahams opened 1 year ago

dabrahams commented 1 year ago
subscript s(_ x: Int): Int {
  let {x}
}

subscript s(_ x: inout Int): Int {
  let {x}
}

fun use<T>(_ x: T) {}

public fun main() {
  use(s[3])
}
Pointers.val:12.3-6: error: not enough contextual information to infer generic arguments
  use(s[3])
  ~~~
Pointers.val:12.7-8: error: incompatible types 'subscript [_] (Int) let : _' and 'subscript [{}] (let Int): Int { let }'
  use(s[3])
      ^
dabrahams commented 1 year ago

Also, poor diagnostic (compare with https://github.com/val-lang/val/issues/689)