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

fastparse 2 usability issues #205

Closed
pshirshov opened this issue Dec 1, 2018 · 1 comment
Closed

fastparse 2 usability issues #205

pshirshov opened this issue Dec 1, 2018 · 1 comment

Comments

@pshirshov
Copy link

pshirshov commented Dec 1, 2018

  1. When we try to port code which was completely legit in fastparse 1, like
  def adt[_: P](sep: P[Unit]): P[AlgebraicType] = P(adtMember.rep(min = 1, sep = sep))

we are getting odd compiler warnings like

a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses

and our parsers are failing with insane errors (like cast exceptions or stack overflows).

fastparse 2 requires all the parsers to combine be defined as by-name parameters but not enforces it. So, the following snippet is correct:

  def adt[_: P](sep: P[Unit]): P[AlgebraicType] = P(adtMember.rep(min = 1, sep = sep))

I think that this behaviour should be enforced somehow - it is possible to verify the nature of the value from within a macro.

  1. Seems like scaladoc fails on expressions with CharsWhileIn:
  final val digits  = "0123456789"
  final val hexDigits = digits + "abcdefABCDEF"
  def HexNum[_: P]: P[Unit] = P("0x" ~ CharsWhileIn(hexDigits))
[error] /work/idealingua/idealingua-core/src/main/scala/com/github/pshirshov/izumi/idealingua/il/parser/structure/syntax/Basic.scala:16:52: Function can only accept constant singleton type
[error]   def HexNum[_: P]: P[Unit] = P("0x" ~ CharsWhileIn(hexDigits))
[error]                                                    ^

The code compiles fine, just scaladoc dies. I guess scaladoc runs before application of these ref transparency optimizations and it's not actually a fastparse issue, but it's very odd and misleading.

@lihaoyi
Copy link
Member

lihaoyi commented Dec 2, 2018

It's a bit hard to generally solve this, but we have some work in progress that might help #204

@lihaoyi lihaoyi closed this as completed Dec 2, 2018
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

No branches or pull requests

2 participants