Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openarray/varargs: Nothing match Foo(bar: openarray[int] or PFoo) #6529

Closed
mratsim opened this issue Oct 18, 2017 · 2 comments
Closed

openarray/varargs: Nothing match Foo(bar: openarray[int] or PFoo) #6529

mratsim opened this issue Oct 18, 2017 · 2 comments
Labels

Comments

@mratsim
Copy link
Collaborator

mratsim commented Oct 18, 2017

This issue gave me the idea of https://github.com/nim-lang/Nim/issues/6528

The following does not compile:

type
  MetadataArray* = object
    data*: array[8, int]
    len*: int


proc foo(a: openarray[int] or MetadataArray)=
  echo "barbaz"

let a = @[1,2]

foo(a)
Error: type mismatch: got (seq[int])
but expected one of:
proc foo(a: openArray[int] or MetadataArray)

varargs have the same issue

@Araq
Copy link
Member

Araq commented Oct 19, 2017

There is a conversion from seq[int] to openArray[int] but conversions are not lifted to | type constructors. Maybe they should, not sure if that's safe to do in general though. Type systems are tricky. But since you live with the generic instantiations already, use a concept instead?

@zah
Copy link
Member

zah commented Oct 20, 2018

Duplicate of #7432

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants