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

for-comprehension with type pattern: enumerator not filtered #1089

Closed
scabug opened this issue Jul 3, 2008 · 3 comments
Closed

for-comprehension with type pattern: enumerator not filtered #1089

scabug opened this issue Jul 3, 2008 · 3 comments

Comments

@scabug
Copy link

scabug commented Jul 3, 2008

Compiling

object Test extends Application {
  val l1 = List(1, "2")
  val l2 = for (i: Int <- l1) yield i+1
}

yields

Test.scala:3: error: type mismatch;
 found   : (Int) => Int
 required: (Any) => ?
  val l2 = for (i: Int <- l1) yield i+1
                ^
one error found

The method TypeBuilder.makeGenerator should transform the generator x: Int <- l1 to

x: Int <- l1.filter {case x: Int => true; case _ => false }

since pattern is not irrefutable for type Any (the list's element type).

@scabug
Copy link
Author

scabug commented Jul 3, 2008

Imported From: https://issues.scala-lang.org/browse/SI-1089?orig=1
Reporter: @lrytz

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone postponed deleted

@scabug
Copy link
Author

scabug commented Feb 14, 2009

@paulp said:
I am closing as a duplicate and consolidating under ticket #900. See also #1673.

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

No branches or pull requests

1 participant