Skip to content

generics: error with multiple types and constraints #7794

@brentp

Description

@brentp

Update: @krux02 has found this happens when constraints are specified. When the constraints are removed the code will compile.

the code below fails with: Error: cannot instantiate Data got: <type int, type float64> but expected: <T: SomeNumber, U: SomeNumber>

type
  Element*[U:SomeNumber] = ref object
    value*: U

  Data*[T:SomeNumber, U:SomeNumber] = ref object
    xs*: seq[T]
    e*: Element[U]

var e = Element[float64](value:2'f64)
var xs = new_seq[int](10)
var d = Data[int, float64](xs:xs, e:e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions