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

SourceLocationMacro on Scala 3 fails in mdoc. #703

Closed
zainab-ali opened this issue Sep 27, 2023 · 1 comment · Fixed by #702
Closed

SourceLocationMacro on Scala 3 fails in mdoc. #703

zainab-ali opened this issue Sep 27, 2023 · 1 comment · Fixed by #702

Comments

@zainab-ali
Copy link
Contributor

The following code in mdoc on Scala 3 fails to compile:

import cats.effect.*
import weaver.*

object MySuite extends SimpleIOSuite {

  val randomUUID = IO(java.util.UUID.randomUUID())

  // A test for side-effecting functions
  test("hello side-effects") {
    for {
      x <- randomUUID
      y <- randomUUID
    } yield expect(x != y)
  }

}

The error is related to the SourceLocationMacro:

Exception occurred while executing macro expansion.
java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:627)
        at scala.None$.get(Option.scala:626)
        at weaver.macros$.fromContextImpl(SourceLocationMacro.scala:28)

The macro calls get on the optional getJPath attribute. This is empty for non-JVM sources such as mdoc files.

I've proposed a workaround in #702 that uses the path attribute as a fallback.

@Baccata
Copy link
Contributor

Baccata commented Sep 27, 2023

Thanks for the PR, I'll cut a release before the end of the week (if I forget, feel free to ping me on the TL discord)

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