Skip to content
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

Routes cannot route a method whose name is a reserved word. #11439

Open
proudust opened this issue Sep 24, 2022 · 1 comment · May be fixed by #11890
Open

Routes cannot route a method whose name is a reserved word. #11439

proudust opened this issue Sep 24, 2022 · 1 comment · May be fixed by #11890

Comments

@proudust
Copy link

Play Version

2.8.16

API

Java 11, and Scala 2.13.9

Operating System

Windows 11

JDK

Microsoft Build of OpenJSK with Hotspot 11.0.16.1+1 (x64)

Expected Behavior

  1. Create methods for Scala reserved words in your Java or Scala Controller class.

  2. Add the method created in 1. to routes.

  3. Run sbt run.

  4. I get a compile error.

Compilation error
identifier expected but 'def' found.

exports, which is a reserved word from Scala3, does not result in a compile error, but a warning is displayed in the console.

[warn] C:\Users\Proudust\source\repos\proudust\play-reserved-word\conf\routes:39:1: Wrap `export` in backticks to use it as an identifier, it will become a keyword in Scala 3.
[warn] GET     /export                     controllers.JavaController.export()

Actual Behavior

It should compile successfully.

@mkurz
Copy link
Member

mkurz commented Sep 26, 2022

I didn't look into the code, however we might be able to escape all the method we generate with backticks, so at least Scala reserved word can be used. However it's not our priority now, since you can easily work around the problem my using other names. If you want to provide a pull request however, feel free to submit one.

@amvanbaren amvanbaren linked a pull request Aug 1, 2023 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants