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

generic object with generic field evaluated too early #5540

Closed
jangko opened this issue Mar 15, 2017 · 4 comments · Fixed by #18062
Closed

generic object with generic field evaluated too early #5540

jangko opened this issue Mar 15, 2017 · 4 comments · Fixed by #18062
Assignees

Comments

@jangko
Copy link
Contributor

jangko commented Mar 15, 2017

type
  Fruit = object
  Yellow = object
    a: int
  
template getColor(x: typedesc[Fruit]): typedesc = Yellow

type
  Banana[T] = object
    b: T
    a: getColor(Fruit) # this one works

  Apple[T] = object
    a: T
    b: getColor(T) # this one failed to compile
    
var x: Banana[int]
x.b = 13
x.a.a = 17
echo x

looks like the compiler evaluate the generic field involving template too early.

error messages:

alias.nim(15, 16) Error: type mismatch: got (typedesc[T])
but expected one of:
template getColor[](x: typedesc[Fruit]): typedesc
@jangko jangko changed the title generic object with generic field evaluated to early generic object with generic field evaluated too early Mar 15, 2017
@zah zah self-assigned this Mar 16, 2017
@stale
Copy link

stale bot commented Aug 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Aug 4, 2020
@jangko
Copy link
Contributor Author

jangko commented Aug 4, 2020

It's still a valid issue.

@timotheecour
Copy link
Member

It's still a valid issue

@jangko how so? see #18062

@jangko
Copy link
Contributor Author

jangko commented May 23, 2021

my comment is to prevent the stale bot closing this.

@stale stale bot removed the stale Staled PR/issues; remove the label after fixing them label May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants