-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5498: error for postfixOps if language feature not enabled #8388
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
Conversation
24590a3
to
584a0f0
Compare
I realised that the current implementation in xs filterNot (ys contains)
Thoughts? |
584a0f0
to
4ec009d
Compare
The community build fails due to the new error. How should we proceed on this one? |
Looking at the log the error seams to be coming from scalap. If your PR requires changes in that project you should first make a PR againts this branch with the requiered changes to scalap, then update the submodule in the current PR to get everything green! |
@OlivierBlanvillain that's what I tried to do with dotty-staging/scala#3, please review and merge 🙂 I guess there will be more errors, I'll fix one by one and ask for help if I am stuck. |
69fd043
to
0fb199b
Compare
I think it makes sense to require postfixOps to write this code, and it also matches what scalac does. |
@@ -1675,6 +1675,9 @@ object desugar { | |||
} | |||
else { | |||
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode) | |||
if (!ctx.featureEnabled(nme.postfixOps)) { | |||
ctx.error(s"Usage of postfix operator `${op.name}`\n add `import scala.language.postfixOps` or enable the compiler flag `-language:postfixOps`", t.sourcePos) |
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.
Can you make the message matches the one used by scalac ?
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.
Like this?
postfix operator ${op.name} needs to be enabled
by making the implicit value scala.language.postfixOps visible.
----
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature needs to be explicitly enabled.
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.
sure
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.
done, I think wrapping the operator name with `` is an improvement though, so I keep this if you don't mind.
67fcc6b
to
5f21014
Compare
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.
LGTM!
moreover: - activate postfixOps for dotty - improve error message in CompilationTest in case one forgot to define `// error` - include errors in case expected or row number does not match - add add/withoutLanguageFeature to TestFlags
5f21014
to
6a65c8e
Compare
resolves #5498. It seems like dotty does not output a warning any more (see for instance: https://scastie.scala-lang.org/L8epbiXgQryCYHRWgbx69g)
I saw that PostFixOp is de-sugared in Desugar and hence not available in Typer (where I would have put the check). That's also the reason why I have put the check in Desugar
Following things to consider: