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

add case in for comprehension. prepare Scala 3.4 #2

Closed
wants to merge 1 commit into from

Conversation

xuwei-k
Copy link
Owner

@xuwei-k xuwei-k commented Dec 26, 2023

Welcome to Scala 3.4.0-RC1 (1.8.0_392, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f
-- Error: ----------------------------------------------------------------------
1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f
  |        ^^^^
  |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean
  |
  |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
  |which will result in a filtering for expression (using `withFilter`).
1 error found
Welcome to Scala 3.3.1 (1.8.0_392, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f
1 warning found
-- Warning: --------------------------------------------------------------------
1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f
  |        ^^^^
  |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean
  |
  |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
  |which will result in a filtering for expression (using `withFilter`).
val res0: List[Int] = List()

scala/scala3@849ee9c

```
Welcome to Scala 3.4.0-RC1 (1.8.0_392, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f
-- Error: ----------------------------------------------------------------------
1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f
  |        ^^^^
  |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean
  |
  |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
  |which will result in a filtering for expression (using `withFilter`).
1 error found
```

```
Welcome to Scala 3.3.1 (1.8.0_392, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f
1 warning found
-- Warning: --------------------------------------------------------------------
1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f
  |        ^^^^
  |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean
  |
  |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
  |which will result in a filtering for expression (using `withFilter`).
val res0: List[Int] = List()
```
@xuwei-k xuwei-k closed this Dec 26, 2023
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

Successfully merging this pull request may close these issues.

1 participant