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

Cannot implement distinct seq with setLen #5090

Closed
endragor opened this issue Dec 4, 2016 · 3 comments
Closed

Cannot implement distinct seq with setLen #5090

endragor opened this issue Dec 4, 2016 · 3 comments

Comments

@endragor
Copy link
Contributor

endragor commented Dec 4, 2016

Sample:

type MySeq = distinct seq[int]

proc setLen(s: var MySeq, newLen: Natural) {.borrow.}

var mySeq = MySeq(newSeq[int]())
mySeq.setLen(10)

Error after codegen:

error: request for member 'Sup' in something not a structure or union
  (&myseq_97061_3173352949) = (TY97041*) setLengthSeq(&((&myseq_97061_3173352949))->Sup, sizeof(NI), ((NI) 10));
                                                                                  ^

Nim d6ab21e

@endragor endragor changed the title Cannot implement distinct seq Cannot implement distinct seq with setLen Dec 4, 2016
@krux02
Copy link
Contributor

krux02 commented Dec 14, 2016

as far as I know distinct is something that you should not use at the moment, better use an object with a single member. This does of course not make this less of a bug.

@Araq
Copy link
Member

Araq commented Dec 14, 2016

That's not true, distinct is used everywhere and the above is just a bug.

@krux02
Copy link
Contributor

krux02 commented Dec 14, 2016

Ok, but I still have a rough memory about a conversation, that involved not using distinct in favor of object.

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

No branches or pull requests

3 participants