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

[SPARK-44407][BUILD][TESTS] Clean up the compilation warnings related to it will become a keyword in Scala 3 and prohibit use these keywords as variable name #43529

Closed
wants to merge 5 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Oct 25, 2023

What changes were proposed in this pull request?

This pr clean up the compilation warnings related to it will become a keyword in Scala 3, additionally, to facilitate future Scala version migration, a new compiler option has been added to prohibit the use of these keywords as variable names.

Why are the changes needed?

There are some literals, such as enum, given, export, etc., using them as variable names in Scala 2.13 will trigger compilation warnings, but this will become a compilation error in Scala 3.

Scala 2.13

Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 17.0.8).
Type in expressions for evaluation. Or try :help.


scala> val enum: Int = 1
           ^
       warning: Wrap `enum` in backticks to use it as an identifier, it will become a keyword in Scala 3. [quickfixable]
val enum: Int = 1


scala> val export: Int = 1
           ^
       warning: Wrap `export` in backticks to use it as an identifier, it will become a keyword in Scala 3. [quickfixable]
val export: Int = 1


scala> val given: Int = 1
           ^
       warning: Wrap `given` in backticks to use it as an identifier, it will become a keyword in Scala 3. [quickfixable]
val given: Int = 1 

Scala 3

Welcome to Scala 3.3.1 (17.0.8, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                                                                                     
scala> val enum: Int = 1
-- [E032] Syntax Error: --------------------------------------------------------
1 |val enum: Int = 1
  |    ^^^^
  |    pattern expected
  |
  | longer explanation available when compiling with `-explain`
                                                                                                                                                                                                                                                     
scala> val export: Int = 1
-- [E032] Syntax Error: --------------------------------------------------------
1 |val export: Int = 1
  |    ^^^^^^
  |    pattern expected
  |
  | longer explanation available when compiling with `-explain`
                                                                                                                                                                                                                                                     
scala> val given: Int = 1
-- [E040] Syntax Error: --------------------------------------------------------
1 |val given: Int = 1
  |         ^
  |         an identifier expected, but ':' found
  |
  | longer explanation available when compiling with `-explain` 

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass GitHub Actions

Was this patch authored or co-authored using generative AI tooling?

No

@LuciferYang LuciferYang changed the title [SPARK-44407][BUILD][TESTS] Clean up the compilation warnings related to it will become a keyword in Scala 3 and prohibit the use of these keywords as variable names. [SPARK-44407][BUILD][TESTS] Clean up the compilation warnings related to it will become a keyword in Scala 3 and prohibit use these keywords as variable name Oct 25, 2023
@LuciferYang
Copy link
Contributor Author

Merged into master for Spark 4.0. Thanks @HyukjinKwon

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM later.

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

Successfully merging this pull request may close these issues.

3 participants