-
Notifications
You must be signed in to change notification settings - Fork 1.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
infix
keyword is allowed where it has no effect, and has undocumented uses
#17738
Labels
area:parser
area:reporting
Error reporting including formatting, implicit suggestions, etc
area:specification
About the WIP Scala 3 Spec
itype:bug
Spree
Suitable for a future Spree
Comments
Sporarum
added
itype:bug
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
May 31, 2023
jchyb
added
area:specification
About the WIP Scala 3 Spec
and removed
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
Jun 1, 2023
We discussed with @mbovel, and while this is way too big to be a Spree issue in itself, subparts seem suitable. |
Sporarum
added
Spree
Suitable for a future Spree
area:reporting
Error reporting including formatting, implicit suggestions, etc
area:parser
labels
Jun 1, 2023
arainko
added a commit
to arainko/dotty
that referenced
this issue
Jun 13, 2023
Disallow `infix` objects by checking for the `infix` modifier in `Checking.scala`. Part of scala#17738
arainko
added a commit
to arainko/dotty
that referenced
this issue
Jun 17, 2023
…ods and implicits Part of scala#17738
mbovel
pushed a commit
that referenced
this issue
Jun 19, 2023
Disallow `infix` objects by checking for the `infix` modifier in `Checking.scala`. Part of #17738
arainko
added a commit
to arainko/dotty
that referenced
this issue
Jul 1, 2023
…ods and implicits Part of scala#17738
mbovel
added a commit
that referenced
this issue
Jul 13, 2023
…7994) Disallow infix toplevel definitions for anything that is not a `class`, `typealias`, `match type`, `extension method` and a `trait` (and `objects` as well but these are handled in their own PR). Part of #17738 Continuation of #17966 --------- Co-authored-by: Matt Bovel <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:parser
area:reporting
Error reporting including formatting, implicit suggestions, etc
area:specification
About the WIP Scala 3 Spec
itype:bug
Spree
Suitable for a future Spree
Compiler version
Tested on 3.3.1-RC1 with
-source:future
, but unlikely to have changedCurrent State
The reference page describing infix calls mentions two places where
infix
is allowed (without saying these are necessarily the only two):and
However, I found
infix
is also allowed in the following (doubles as example for later):Notably,
infix
is not allowed onimport
andexport
toplevel
can never be called as infix, the intent was probably aninfix
extension methodI would have expected to be able to call for example
v
in an infix matter, this is not allowed,all of the following throw "expression expected but end of statement found" (also the case if we remove the
infix
s):If we add right-hand sides, we have the following:
But neither
O
norC
are methods, and more importantly, they are bothinline
!And finally if we remove
infix
from the definitions, we get this (with shortened warnings):As we can see, neither
v
norg
emit a warning !(This might be because
Function1.apply
was compiled with Scala 2)Adding
infix
toO.apply
leads to no warnings, whether or notO
is itselfinfix
!The reference is also silent on types taking any other amount than 2 parameters, here is what I found:
The following is also undocumented:
Summary
infix
is valid, and has undocumented positive effect ontrait
s andclasses
taking exactly 2 type parameters, andtypes
taking 0 parameters.infix
is valid, but has no effect onval
,object
,given
, as well as in the following particular cases:type
not taking 0 or 2 parametersclass
ortrait
not taking 2 parameterdef
def
taking 0 parameters (behaves the same asv
above)Expectation
infix
should only be allowed in front of constructs it can modify. Currently:def
,type
,trait
,class
In other cases, it should return a similar error as
infix export
, or a better oneIn cases where
infix
has no effect (currently: "particular cases" above), a warning should be emittedEvery
ninfixN
should throw a "not infix" warningThe following should display a special warning:
infix
auxiliary constructors should be either documented, emit a warning, or throw an errorThe text was updated successfully, but these errors were encountered: