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

Strange behavior of "unzip" function #10087

Closed
scabug opened this issue Dec 2, 2016 · 2 comments
Closed

Strange behavior of "unzip" function #10087

scabug opened this issue Dec 2, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented Dec 2, 2016

I have this piece of code:

val s: String = "Hello World!"
val pair = List(1, 2, 3, 4)

val p01 = pair zip s
val p02 = s zip pair

If i use those expressions
p01 unzip (line1)
p02 unzip (line2)

I get an warning on Line1 (postfix operator unzip should be enabled by making the implicit value scala.language.postfixOps visible.)
and an error on Line2.

  1. if I add "import scala.language.postfixOps" the warning goes away but the error stay.

  2. if I keep the import and add ";" after line1 everything it's fine!

  3. if I keep the import and add a blank line between line1 and line2 it's fine also!

  4. Interesting: If I do not have the import statement but keep a blank line between two lines
    I get the warnings but it works.

I've seen this behavior so far only for "unzip".

Here's the code:
"
val s: String = "Hello World!"
val pair = List(1, 2, 3, 4)

val p01 = pair zip s
val p02 = s zip pair

//import scala.language.postfixOps

//if I have a line in between or ";" after the first line no warnings or errors!
p01 unzip
p02 unzip
*/

@scabug
Copy link
Author

scabug commented Dec 2, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10087?orig=1
Reporter: Iani Loghin (ianilo)

@scabug
Copy link
Author

scabug commented Dec 2, 2016

@SethTisue said:
The unfortunate interaction of language.postfixOps with semicolon inference is exactly the reason why the postfix syntax was put behind a flag. It's better not to use or enable this feature at all.

You're experiencing this with "unzip" in particular because it takes an implicit parameter list.

@scabug scabug closed this as completed Dec 2, 2016
@scabug scabug added the quickfix label Apr 7, 2017
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