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

lazy val seems to be evaluated eagerly #179

Closed
valydia opened this issue Jul 5, 2019 · 1 comment
Closed

lazy val seems to be evaluated eagerly #179

valydia opened this issue Jul 5, 2019 · 1 comment

Comments

@valydia
Copy link
Contributor

valydia commented Jul 5, 2019

When I try to generate the doc for the following sample:

```scala mdoc
lazy val valueOpt: Option[Int] = ???
```

I get the following error:

an implementation is missing
lazy val valueOpt: Option[Int] = ???
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scala.NotImplementedError: an implementation is missing
        at scala.Predef$.$qmark$qmark$qmark(Predef.scala:288)
...

I would expect this to compile as it works with tut see this file (line 237).

@olafurpg
Copy link
Member

Thank you for reporting! It's correct that lazy vals are currently eagerly evaluated. We can change the instrumentation to not evaluate lazy vals by changing the code somewhere around here

private def printBinder(name: String, pos: Position): Unit = {
sb.print(s"; $$doc.binder($name, ${position(pos)})")
}

A pull request making the behavior consistent with tut would be welcome!

olafurpg added a commit that referenced this issue Oct 4, 2019
Evaluate lazy vals lazily (fixes #179)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants