Skip to content

Desugaring of given in for expressions #10990

Closed
@joschua-fink

Description

@joschua-fink

Minimized example

import monix.eval.Task

for {
  given Boolean <- Task.now(true)
} yield ()

Output

Without -source 3.1 in Scala 3.0.0-M3

[error] -- [E008] Not Found Error:
[error] 7 |  given Boolean <- Task.now(true)
[error]   |                   ^^^^^^^^^^^^^^
[error]   |value withFilter is not a member of monix.eval.Task[Boolean], but could be made available as an extension method.

With -source 3.1 compiles without any complaint.

Expectation

I'm not sure if this behavior is a bug or an intended side effect of the changes to pattern bindings.

If it is not a bug, I would welcome having it documented clearly. It is hinted to in: https://dotty.epfl.ch/docs/reference/changed-features/pattern-bindings.html but I first looked in https://dotty.epfl.ch/docs/reference/contextual/givens.html and was quite puzzled why it wasn't working, since I wasn't expecting to desugar the above example to a withFilter, when a variant without given was working fine without using withFilter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:desugarDesugaring happens after parsing but before typing, see desugar.scala

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions