Skip to content

wrong error for method with name inline: inline must be followed by an if or a match #11860

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

Closed
unkarjedy opened this issue Mar 23, 2021 · 3 comments

Comments

@unkarjedy
Copy link
Contributor

unkarjedy commented Mar 23, 2021

Compiler version

3.0.0-RC2-bin-20210317-758782a-NIGHTLY

Minimized code

object SoftModifierTests {
  def main(args: Array[String]): Unit = {
    def inline(): Unit = println("do some work...")
    inline()
  }
}

Output

Error

`inline` must be followed by an `if` or a `match`
    inline()

Expectation

According to the spec https://dotty.epfl.ch/docs/reference/soft-modifier.html inline should be treated as a normal identifier:

  • it's not followed by if or match
  • it's not followed by parameter definition
  • it's not followed by hard modifier
  • it's not followed by class, trait, etc...
  • Everywhere else a soft keyword is treated as a normal identifier

and the code should compile

image

@unkarjedy
Copy link
Contributor Author

checked with:

scalaVersion := "3.0.0-RC2-bin-20210320-0195dff-NIGHTLY",
scalaVersion := "3.0.0-RC2-bin-20210322-4035f51-NIGHTLY",

seeing the same error

@nicolasstucki
Copy link
Contributor

odersky added a commit to dotty-staging/dotty that referenced this issue Mar 25, 2021
@odersky
Copy link
Contributor

odersky commented Mar 25, 2021

The docs promised too much here. The problem is that the parser would need unlimited lookahead to decode whether inline is followed by a match. I changed the doc page to conform to the Parser's behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants