hylo-lang / hylo

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

Remote types cause type inference to fail #1401

Open dabrahams opened 7 months ago

dabrahams commented 7 months ago

At 3a3f5a0 typecheck:

type MutableArraySlice<T: SemiRegular>: MutableCollection {

  memberwise init

  var core: remote inout Array<T>
  var start_position_: Position
  var end_position_: Position

  public typealias Position = Int
  public typealias Element = T

  public fun start_position() -> Position { core.start_position() }
  public fun end_position() -> Position { core.end_position() }
  public fun position(after i: Position) -> Position {  core.position(after: i) }

  public subscript(_ i: Position): Element { let { yield core[i] } inout { yield &core[i] } }

  public fun swap_at(_ i: Position, _ j: Position) inout {
    core.swap_at(i, j)
  }
}

Result:

slice2.hylo:12.45-69: error: not enough contextual information to infer generic arguments
  public fun start_position() -> Position { self.core.start_position() }
                                            ~~~~~~~~~~~~~~~~~~~~~~~~
slice2.hylo:13.43-65: error: not enough contextual information to infer generic arguments
  public fun end_position() -> Position { self.core.end_position() }
                                          ~~~~~~~~~~~~~~~~~~~~~~
slice2.hylo:14.57-70: error: not enough contextual information to infer generic arguments
  public fun position(after i: Position) -> Position {  core.position(after: i) }
                                                        ~~~~~~~~~~~~~
slice2.hylo:19.5-17: error: not enough contextual information to infer generic arguments
    core.swap_at(i, j)
    ~~~~~~~~~~~~

There are no obvious generic arguments to infer here; seems like it should work.

kyouko-taiga commented 7 months ago

I think the bug is linked to the use of a remote type.