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

Unbound placeholder parameter error in worksheets with Dotty #2076

Closed
ckipp01 opened this issue Sep 17, 2020 · 5 comments · Fixed by #2079
Closed

Unbound placeholder parameter error in worksheets with Dotty #2076

ckipp01 opened this issue Sep 17, 2020 · 5 comments · Fixed by #2079
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket Scala 3 Generic ticket relating to Scala 3 worksheets Use for tickets related to worksheets
Milestone

Comments

@ckipp01
Copy link
Member

ckipp01 commented Sep 17, 2020

Describe the bug
Given the following code snippet in a worksheet with dotty...

def x = 1 -> 2
val (a, _) = x

...you'll see an error.

[mdoc] [E] scala.worksheet.sc:14 (mdoc generated code) Unbound placeholder
  parameter; incorrect use of _
     $doc.binder(_, 2, 8, 2, 9)

384

To Reproduce
Steps to reproduce the behavior:

  1. Paste the code snippet above in a Dotty worksheet
  2. Evaluate and see error

Expected behavior
This works fine in Scala 2 and is valid syntax afaik in Scala 3. This shouldn't give this error message.

Installation:

  • Operating system: macOS
  • Editor: Vim
  • Metals version: 0.9.3+102-31fb9f1e-SNAPSHOT

Additional context
I'm still trying to figure out what exact placeholder syntax triggers this which doesn't some of the other types of placeholder syntaxes I've tried doesn't seem to be an issue like this one is.

cc @eloots

Search terms
placeholder syntax, dotty, worksheets

@ckipp01 ckipp01 added bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 worksheets Use for tickets related to worksheets labels Sep 17, 2020
@tgodzik
Copy link
Contributor

tgodzik commented Sep 17, 2020

Thanks for finding this! The problem is most likely in mdoc, I am not super sure why this is, but it should be easily reproducible in the tests.

@tgodzik tgodzik added the upstream-fix-needed Waiting on a fix upstream label Sep 17, 2020
@ckipp01
Copy link
Member Author

ckipp01 commented Sep 18, 2020

So from looking at the evaluated document in Scala 2.x we get:

EvaluatedDocument(Input.VirtualFile("placeholder.scala", "package repl
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {
  def app(): _root_.scala.Unit = {val _ = new App()}
  class App {
$doc.startSection();
$doc.startStatement(0, 0, 0, 14);
def x = 1 -> 2
$doc.endStatement();
$doc.startStatement(1, 0, 1, 14);
val (a, _) = x; $doc.binder(a, 1, 5, 1, 6)
$doc.endStatement();
$doc.endSection();
  }
}

With Dotty it looks like so:

EvaluatedDocument(Input.VirtualFile("placeholder.scala", "package repl
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {
  def app(): _root_.scala.Unit = {val _ = new App()}
  class App {
    $doc.startSection();
    $doc.startStatement(0, 0, 0, 14);
    def x = 1 -> 2
    $doc.endStatement();
    $doc.startStatement(1, 0, 1, 14);
    val (a, _) = x
    $doc.binder(a, 1, 5, 1, 6)
+   $doc.binder(_, 1, 8, 1, 9)
    $doc.endStatement();
    $doc.endSection();
  }
}

I'm going to make a wild guess and say that the $doc.binder(_, 1, 8, 1, 9) should just be skipped like it is in Scala 2.x. At least that's the route I'm heading and trying to figure out.

@tgodzik
Copy link
Contributor

tgodzik commented Sep 18, 2020

@tgodzik
Copy link
Contributor

tgodzik commented Sep 18, 2020

Do you want to take a look at it or should I try to fix it? @ckipp01

@ckipp01
Copy link
Member Author

ckipp01 commented Sep 18, 2020

Do you want to take a look at it or should I try to fix it? @ckipp01

I'm actually looking at it right now. So I'll ping you if I get stuck 😆

@tgodzik tgodzik added fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket and removed upstream-fix-needed Waiting on a fix upstream labels Sep 18, 2020
@tgodzik tgodzik modified the milestones: Metals v0.9.4, Metals v0.9.5 Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket Scala 3 Generic ticket relating to Scala 3 worksheets Use for tickets related to worksheets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants