Skip to content

DottyDoc ignores precedence when pretty-printing types in RenderReference #4966

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

Closed
Blaisorblade opened this issue Aug 20, 2018 · 1 comment
Closed

Comments

@Blaisorblade
Copy link
Contributor

Blaisorblade commented Aug 20, 2018

Based on code inspection, it seems like both RenderReference and ReferenceShower (which should disappear in #4954) ignore precedence: you'd get A & B => C from both (A & B) => C and A & (B => C), and one would have have similar issues whenever combining operators with different precedence.

I confirmed this by compiling the following source (placed in dotty/doc-tool/src/dotty/tools/dottydoc/model/TestDoc.scala), running dotty-doc/genDocs, and then opening dotty/docs/_site/api/dotty/tools/dottydoc/model/TestDoc.html (search didn't find that file, somehow, not sure how I should run doc generation).

package dotty.tools.dottydoc.model

trait TestDoc {
  type A
  type B
  type C
  val f1: (A with B) => C
  val f2: A with (B => C)
}
@Blaisorblade
Copy link
Contributor Author

Since this code is easier to test before producing the HTML (as done in https://github.com/lampepfl/dotty/pull/4954/files#diff-163c987fd3c448d3726f1715eb6a05cd), I'd think about adding a ParensReference node, that is rendered by simply adding parentheses around the node. I'd keep that separate from unary tuples, in case different formatting is needed and/or Dotty does add unary tuples (as Martin seems to have mentioned).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants