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

ScalaDoc generation fails with pattern matches [WORKAROUND AVAILABLE] #119

Open
tafli opened this issue Aug 14, 2017 · 7 comments
Open

ScalaDoc generation fails with pattern matches [WORKAROUND AVAILABLE] #119

tafli opened this issue Aug 14, 2017 · 7 comments
Assignees
Labels
Milestone

Comments

@tafli
Copy link

tafli commented Aug 14, 2017

We're using the newest version and tried pattern matching with guards as in the examples:

implicit val numericValidator = validator[ NumericPair ] { pair =>
pair.numeric match {
    case n if n < 0 => pair.string should startWith( "-" )
    case 0             => pair.string is equalTo( "0" )
    case n if n > 0 => pair.string is notEmpty
  }
}

Everything works fine with compiling and running but publishing fails as ScalaDoc seems to have a problem with the guards (without the guard its fine):

$ sbt doc
....
[info] This is a scaladoc compilation, Linter is disabled.
[error] <Accord>:1: not a legal formal parameter.
[error] Note: Tuples cannot be directly destructured in method or function parameters.
[error]       Either create a single parameter accepting the Tuple1,
[error]       or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
[error] n < 0 => 
[error]   ^
[error] <Accord>:1: illegal start of simple expression
[error] n < 0 => 
[error]         ^
[info] No documentation generated with unsuccessful compiler run
[error] two errors found
[error] (compile:doc) Scaladoc generation failed
....

Any ideas what the problem is?

Many thanks!

@holograph holograph self-assigned this Aug 15, 2017
@holograph
Copy link
Contributor

That is strange, I wonder what kind of weird magic goes on there. I'll look into it tomorrow and will let you know what I find.

@holograph
Copy link
Contributor

Oh, and if you have a reproduction case you can share (ideally a repo I can clone or something similar), it'll save some time :-)

@holograph
Copy link
Contributor

Well, I managed to reproduce this quite easily. I still have no idea what's going on here, but I'll see what I can do about it.

@holograph holograph added the bug label Aug 16, 2017
@holograph holograph added this to the 0.8 milestone Aug 16, 2017
@tafli
Copy link
Author

tafli commented Aug 16, 2017

Great to hear you could reproduce it. Didn't manage to have a repo to reproduce.

@holograph
Copy link
Contributor

Although I don't understand the issue properly yet, with some assistance from @eed3si9n there is at least a workaround: disabling macro expansions on the doc task. Add this to your build.sbt:

scalacOptions in (Compile, doc) += "-Ymacro-no-expand"

I've verified that this works on a sample repo: https://github.com/holograph/accord-issue119-sample

I'll keep this bug open for future investigation.

@holograph holograph changed the title Pattern-Matching with guards and scala-doc does not work ScalaDoc generation fails with pattern matches [WORKAROUND AVAILABLE] Aug 17, 2017
@cwei-bgl
Copy link

Hi, Is there an update on this?

With Scala version 2.12.4, it is not compiling even. I cannot do with the option -Ymacro-no-expand(-Ymacro-expand:none in new version), as I am using akka-http micro. Thanks.

@holograph
Copy link
Contributor

I'm sorry to say that there hasn't, yet. I'm unclear on why the workaround doesn't work for you, though -- what does akka-http have to do with this?

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