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 instantiate call in default param #5595

Closed
dom96 opened this issue Mar 22, 2017 · 1 comment
Closed

Cannot instantiate call in default param #5595

dom96 opened this issue Mar 22, 2017 · 1 comment
Assignees
Labels

Comments

@dom96
Copy link
Contributor

dom96 commented Mar 22, 2017

Not sure if this should work, but here it is anyway. It gives a "cannot instantiate" error.

type
  Point*[T] = object
    x*, y*: T

proc getOrigin[T](): Point[T] = Point[T](x: 0, y: 0)


proc rotate*[T](point: Point[T], radians: float,
                origin = getOrigin[T]()): Point[T] =
  discard
@dom96 dom96 added the Generics label Mar 22, 2017
@jangko
Copy link
Contributor

jangko commented Mar 23, 2017

Non generic version like code below works well, so the above one should work too. I believe it suffer from generic early evaluation syndrom similar to #5540

type
  Point* = object
    x*, y*: int

proc getOrigin(): Point = Point(x: 0, y: 0)

proc rotate*(point: Point, radians: float,
                origin = getOrigin()): Point =
  discard

@zah zah self-assigned this Mar 23, 2017
zah added a commit that referenced this issue Jun 12, 2018
* late instantiation for the generic procs' default param values
* automatic mixin behaviour in concepts

Other fixes:

* don't render the automatically inserted default params in calls
* better rendering of tyFromExpr
zah added a commit that referenced this issue Jun 16, 2018
* late instantiation for the generic procs' default param values
* automatic mixin behaviour in concepts

Other fixes:

* don't render the automatically inserted default params in calls
* better rendering of tyFromExpr
zah added a commit that referenced this issue Jun 16, 2018
* late instantiation for the generic procs' default param values
* automatic mixin behaviour in concepts

Other fixes:

* don't render the automatically inserted default params in calls
* better rendering of tyFromExpr
@Araq Araq closed this as completed in 5bcf8bc Jun 26, 2018
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

3 participants