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

Scala 3.2 regex deconstruction warnings #101

Open
ekrich opened this issue Jan 27, 2023 · 0 comments
Open

Scala 3.2 regex deconstruction warnings #101

ekrich opened this issue Jan 27, 2023 · 0 comments

Comments

@ekrich
Copy link
Owner

ekrich commented Jan 27, 2023

Code in Instant and LocalDate:

val pattern = """(^[-+]?)(\d*)-(\d*)-(\d*)""".r
val pattern(sign, yearSegment, monthSegment, daySegment) = text

From compiling:

[warn] -- Warning: /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/Instant.scala:391:17 
[warn] 391 |      val pattern(sign, yearSegment, monthSegment, daySegment,
[warn]     |          ^
[warn]     |pattern binding uses refutable extractor `pattern`
[warn]     |
[warn]     |If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
[warn]     |which may result in a MatchError at runtime.
[warn]     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.
[warn] 392 |          hourSegment, minutesSegment, secondsSegment, nanosecondsSegment) = text
[warn] -- Warning: /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/Instant.scala:391:17 
[warn] 391 |      val pattern(sign, yearSegment, monthSegment, daySegment,
[warn]     |          ^
[warn]     |pattern binding uses refutable extractor `pattern`
[warn]     |
[warn]     |If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
[warn]     |which may result in a MatchError at runtime.
[warn]     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.
[warn] 392 |          hourSegment, minutesSegment, secondsSegment, nanosecondsSegment) = text
[warn] -- Warning: /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/LocalDate.scala:446:17 
[warn] 446 |      val pattern(sign, yearSegment, monthSegment, daySegment) = text
[warn]     |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn]     |pattern binding uses refutable extractor `pattern`
[warn]     |
[warn]     |If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
[warn]     |which may result in a MatchError at runtime.
[warn]     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.
[warn] -- Warning: /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/LocalDate.scala:446:17 
[warn] 446 |      val pattern(sign, yearSegment, monthSegment, daySegment) = text
[warn]     |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn]     |pattern binding uses refutable extractor `pattern`
[warn]     |
[warn]     |If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
[warn]     |which may result in a MatchError at runtime.
[warn]     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.
[warn] two warnings found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant