-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Deprecate procedure syntax without -Xfuture #6325
Conversation
you're on a roll! |
restype = scalaUnitConstr | ||
} | ||
newmods |= Flags.DEFERRED | ||
EmptyTree | ||
} else if (restype.isEmpty && in.token == LBRACE) { | ||
if (settings.future) | ||
deprecationWarning(in.offset, s"Procedure syntax is deprecated. Convert procedure `$name` to method by adding `: Unit =`.", "2.12.0") | ||
if (settings.isScala214) syntaxError(in.lastOffset, msg("unsupported")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defmsg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch.
This comment has been minimized.
This comment has been minimized.
to facilitate review, let's not squash until we're totally ready to merge this. (the full, combined diff is........ l-o-n-g.......) @eed3si9n you didn't write it, but I think the "convert procedure to method" wording in the error message is... not ideal. "procedures" are still methods, they aren't some entirely separate category. also, "add how about replacing "convert..." with simply "instead, add |
@@ -2718,18 +2718,20 @@ self => | |||
val vparamss = paramClauses(name, contextBoundBuf.toList, ofCaseClass = false) | |||
newLineOptWhenFollowedBy(LBRACE) | |||
var restype = fromWithinReturnType(typedOpt()) | |||
def msg(what: String) = s"procedure syntax is $what. convert procedure `$name` to method by adding `: Unit`." | |||
def defmsg(what: String) = s"procedure syntax is $what. convert procedure `$name` to method by adding `: Unit =`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SethTisue =
I think is in the error message when it is a definition. Do you have a negative test link that shows otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I missed that, nm.
before
after
With either of these messages, is it be clear for the users to know what to do? Problem 1-B: Suppose the user, who is otherwise proficient in Scala, has never heard of the term "procedure syntax." |
I don't mean to be flip, but: they can Google it? I don't see a way to do better without writing a substantially longer error message. (doing that wouldn't be a bad idea, but I think the PR is mergeable regardless.) maybe "procedure syntax is deprecated: instead, add |
+1 on "procedure syntax is deprecated: instead, add |
5c1e1dd
to
e4e6a3b
Compare
Ping? |
It would be good if we expedited this a bit in order for Eugene not to have to do a bunch of annoying rebases. I’ll try to take a final look this week. |
Did some rebasing and squashing to compensate for my tardiness. Hope you won't mind my |
b985e62
to
814674a
Compare
restype = scalaUnitConstr | ||
} | ||
newmods |= Flags.DEFERRED | ||
EmptyTree | ||
} else if (restype.isEmpty && in.token == LBRACE) { | ||
if (settings.future) | ||
deprecationWarning(in.offset, s"Procedure syntax is deprecated. Convert procedure `$name` to method by adding `: Unit =`.", "2.12.0") | ||
if (settings.isScala214) syntaxError(in.lastOffset, msg("unsupported", ": Unit =")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error should probably be positioned at in.offset
. I'll push a fix once I've updated the check files
55bf785
to
e13047c
Compare
Just realized the last two commits will need another rebase since we'll merge the new collections first. (One line in src/compiler/scala/tools/nsc/ast/parser/xml/MarkupParserCommon.scala and 29 tests.) |
e13047c
to
380a1b6
Compare
@eed3si9n sorry, could we ask you for one more rebase, then we'll merge? |
(P.S. if you're worried that our current merge promises are no more trustworthy than previous ones :-/, you might consider splitting this into two PRs, one big one that just removes uses of procedure syntax codebase-wide — since we could easily merge that the moment Jenkins liked it, there's no downside — and then a second, small PR that does the deprecation.) |
380a1b6
to
4ff0e11
Compare
Given that the collection library is merged, I am hoping that there's no more blockers to this PR once all the tests pass. |
go Jenkins go! |
tests need updating. even the first commit fails, probably because the collections merge introduced new tests that are now causing deprecation warnings. |
@eed3si9n wouldn't it minimize churn if you first got rid of all the uses, then deprecated? if done in that order, the deprecation commit would be small. |
I don't think the ordering changes things as long as it affects a bunch of files, and if it stays open for months, assuming that deprecation itself is not blocked/controversial. |
I originally had it |
okay. regardless, I'm standing by to hit "merge" as soon as Jenkins likes it. |
Procedure syntax was deprecated under -Xfuture flag in scala#3076. This deprecates it unconditionally, and drops it under -Xsource:2.14. See scala/bug#7605 To update the tests, this drops procedure syntax from test/ using ScalaFix ``` $ coursier launch ch.epfl.scala:scalafix-cli_2.12.3:0.5.3 -- -r ProcedureSyntax test $ coursier launch ch.epfl.scala:scalafix-cli_2.12.4:0.5.10 -- -r ExplicitUnit test ```
``` $ coursier launch ch.epfl.scala:scalafix-cli_2.12.3:0.5.3 -- -r ProcedureSyntax src/compiler $ coursier launch ch.epfl.scala:scalafix-cli_2.12.4:0.5.10 -- -r ExplicitUnit src/compiler ```
4ff0e11
to
cc0857e
Compare
@SethTisue Rebased and squashed. |
your revenge is that now everybody else has to rebase their PRs 😁 |
thank you, Eugene |
Thanks for the merge! |
this came up at the SIP meeting today. I get a deprecation warning with the M5 compiler:
but in the REPL, I don't:
|
@som-snytt @adriaanm any clue why this might be happening, where an investigation should start? |
From now on, "procedure syntax" will refer only to the order and form of the words you must use at a SIP meeting to get your point across. |
I'll take that as a "no" :-) |
I'll take a closer look. Deprecation works in general. So it's not a lost flag. BTW Also Looks like just the parser deprecations aren't forwarded.
|
def parse(line: String): Either[Result, (List[Tree], Position)] = {
var isIncomplete = false
currentRun.parsing.withIncompleteHandler((_, _) => isIncomplete = true) {
withoutWarnings { REPL parsing code is silencing all warnings. |
This was added in #5647 to fix scala/bug#10130 about multiple warnings showing up. |
It parses again after templating, IIRC. Edit: I see that's my comment on the PR you point out. I thought maybe I broke something in touching the reporters. |
On 2.13.x, it seems to work without
|
OK, good! I see, Adriaan keeps the trees and splices it into the template. |
In scala#6325 Seth reported that procedure syntax deprecation warnings are not displayed on REPL. This is because warnings were filtered out by `withoutWarnings` in scala#5647 to fix scala/bug#10130. On 2.13.x, it seems to work ok without the `withoutWarnings` filter during parse.
Ref scala/bug#7605
#3076 deprecated the procedure syntax, but only under -Xfuture flag. This deprecates it without it, and drops it under
-Xsource:2.14
.This PR also migrates all code under
src/compiler/
andtest/
to: Unit =
-style, mostly automatically by using ScalaFix's ProcedureSyntax (and ExplicitUnit, which will be merged to ProcedureSyntax) rule.