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

"not found" error when a closure on right side of binding uses val #53

Open
toby5box opened this issue Mar 9, 2022 · 0 comments
Open

Comments

@toby5box
Copy link

toby5box commented Mar 9, 2022

I had a compilation issue in production code today that I couldn't explain, so I reduced it to a minimal case:

import cats.effect.IO

object DeleteMe {
  // I am using this - see: https://github.com/oleg-py/better-monadic-for
  // addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")

  def test_OK = {
    for {
      (a,b,c) <- IO.pure( (1,2,3) )
    } yield a+b+c
  }

  def test_bad = {
    for {
      (a, b, c) <- IO.pure(11).map{ _ =>
        val g = 3     // <--- Any binding here causes compile to fail
        (1,2,3)
      }
    } yield a + b + c   // compiler says 'not found' for each of these
  }

}

Not sure if I am missing something, but adding that val binding causes the compile to fail, e.g.

[error] /x/DeleteMe.scala:21:13: not found: value a
[error]     } yield a + b + c   // compiler says 'not found' for each of these
[error]             ^
[error] /x/DeleteMe.scala:21:17: not found: value b
[error]     } yield a + b + c   // compiler says 'not found' for each of these
[error]                 ^
[error] /x/DeleteMe.scala:21:21: not found: value c
[error]     } yield a + b + c   // compiler says 'not found' for each of these
[error]                     ^
[error] three errors 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