Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Unable to explicitly create an instantiation of a generic struct / create generic struct with array #40

Open
lefticus opened this issue Mar 8, 2024 · 1 comment

Comments

@lefticus
Copy link
Collaborator

lefticus commented Mar 8, 2024

Type inference works, if I have a value to pass to the generic's construction, but that doesn't always make sense if I want to create an empty container, then fill it later.

struct Array<Contained> {
  width: i64
  height: i64
  contents: raw[Contained] 

  fun create_array(width_: i64, height_: i64) -> Array {
    mut array = new Array(width: width_, height: height_, contents: raw[])
    let size = width_ * height_
    unsafe { resize array.contents size }
    return array
  }
}


// works
let data = new Array(2,3,raw[false])

// does not work
// let data = Array<bool>::create_array(10, 12)
@lefticus
Copy link
Collaborator Author

lefticus commented Mar 9, 2024

I'm now unable to compile this example and feeling very confused. I was certain it was working a moment ago

@lefticus lefticus changed the title Unable to explicitly create an instantiation of a generic struct Unable to explicitly create an instantiation of a generic struct / create generic struct with array Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant