Thanks to visit codestin.com
Credit goes to github.com

Skip to content

x op () now parses as x.op(()) not x.op() #7684

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

Merged
merged 1 commit into from
Jan 25, 2019

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jan 25, 2019

Previously, x op() was incorrectly taken as x.op().

Now it is correctly parsed as x.op(()), where unit value is an operand in the expression x op ().

Previously, () == () would warn about adapting ().==() to ().==(()).

When parsing infix expression, a Parens node
is created for parens. If it is empty, they
wrote unit value. Otherwise, per the spec,
the several comma-separated arguments
are taken as arguments. (A single operand
in parens is just a single argument, as usual.)

Split from the rebasing hamster wheel at #6974

@scala-jenkins scala-jenkins added this to the 2.13.0-RC1 milestone Jan 25, 2019
When parsing infix expression, a Parens node
is created for parens. If it is empty, they
wrote unit value. Otherwise, per the spec,
the possibly many comma-separated arguments
are taken as arguments.

`() == ()` is now what it looks like.

`x op()` is corrected to `x.op()`.
@adriaanm adriaanm added the release-notes worth highlighting in next release notes label Jan 25, 2019
@adriaanm adriaanm merged commit e4fe8ea into scala:2.13.x Jan 25, 2019
@som-snytt som-snytt deleted the issue/infix-parens branch January 25, 2019 16:16
@SethTisue
Copy link
Member

before:

scala 2.13.0-M5> 3 toString()
res4: String = 3

after:

scala> 3 toString()
         ^
       error: no arguments allowed for nullary method toString: ()String

because it's being taken as if I'd written:

scala> 3.toString(())
                  ^
       error: no arguments allowed for nullary method toString: ()String

this doesn't seem to match what you wrote above, namely "x op() is corrected to x.op()"?

SethTisue added a commit to scalacommunitybuild/scalatest that referenced this pull request Jan 25, 2019
@SethTisue
Copy link
Member

SethTisue commented Jan 25, 2019

discovered because it broke ScalaTest in the 2.13 community build. I had to:

-        outputStream getChannel() transferFrom(Channels.newChannel(inputStream), 0, Long.MaxValue)
+        outputStream.getChannel().transferFrom(Channels.newChannel(inputStream), 0, Long.MaxValue)

not sure how widespread breakage is.

@som-snytt
Copy link
Contributor Author

som-snytt commented Jan 25, 2019

@SethTisue sorry, what I meant was, "I corrected the spots in the compiler where they wrote x op()."

I noticed it here: #6974 (comment)

I think the bad syntax hearkens back to the loose days when folks decided that dots were optional everywhere, the way they once started saying that braces and parens are interchangeable.

Edit: also that parens are optional everywhere, like clothing. What decadent times!

@som-snytt
Copy link
Contributor Author

som-snytt commented Jan 25, 2019

@SethTisue I rediscovered how to look at the community build runs; it's a bit hard to just find the first error; if I see that something isn't building, is the protocol to PR upstream or do something so the CB project can try it out?

Edit: I see that there are local projects I could PR to.

@SethTisue
Copy link
Member

SethTisue commented Jan 26, 2019

@som-snytt it's okay, I'm on it, usually it's easiest for me to just do the needed tweaks myself. for others to try to navigate community build stuff is usually an unnecessary time sink for them. in cases where I need help, I'll ask for it :-)

in this case I dealt with ScalaTest via scalacommunitybuild/scalatest@81302db , I'm currently seeing how much other breakage there is, but I have several other 2.13.x breakages (unrelated to this PR) I also need to address at the same time... I'll come back here once the dust has settled somewhat.

@som-snytt
Copy link
Contributor Author

I won't bug you about it now. I thought I was running a local build just for utest, but I guess it's doing the full suite. I had exercised dbuild once before and fixed something somewhere, so I know it's possible. Probably I was in better shape back then.

@SethTisue
Copy link
Member

SethTisue commented Jan 26, 2019

but I guess it's doing the full suite

it extracts dependencies for everything even if you are only actually building a subset, could be what you're seeing. and for the first run, extract dependencies from 180 repositories takes a looooong time (after that the results are cached, unless you change the Scala SHA or something else fundamental).

usual workaround if you are working on something at least somewhat near the root (like utest or cats) is to delete everything in community.dbuild below the project you care about. (I do my best to keep the file ordered in such a way that this works.)

@SethTisue
Copy link
Member

SethTisue commented Jan 30, 2019

so far it's looking like breakage is not that common 👍

retronym added a commit to retronym/compiler-benchmark that referenced this pull request Feb 4, 2019
SethTisue added a commit to SethTisue/scalatest that referenced this pull request Feb 12, 2019
@SethTisue
Copy link
Member

SethTisue commented Apr 8, 2019

@som-snytt would you mind updating the PR description to include a bit of motivation, aimed at end users who are seeing the change and wondering what the story is? (example: scala/bug#11475)

@som-snytt
Copy link
Contributor Author

@SethTisue maybe also promote the message improvement to RC2 scala/bug#11461

@SethTisue
Copy link
Member

SethTisue commented Apr 8, 2019

@som-snytt new description is better, thanks.

re 11461, I think a fix would be accepted for RC2, but I'd prefer not to put any non-blocker bugs on the milestone

@SethTisue SethTisue changed the title Retain empty parens as unit value x op () now parses as x.op(()) not x.op() Apr 9, 2019
@SethTisue
Copy link
Member

SethTisue commented Apr 9, 2019

I've improved the title as well. (in dem Release-Notes auch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants