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

Unhygienic syntax transformation during type checking #10170

Closed
scabug opened this issue Feb 2, 2017 · 4 comments
Closed

Unhygienic syntax transformation during type checking #10170

scabug opened this issue Feb 2, 2017 · 4 comments

Comments

@scabug
Copy link

scabug commented Feb 2, 2017

The following code:

val a = 100; ({ val a = 0; (c: Int) => c })(a)

Evaluates to 0.
This is because it is transformed by the typer to:

val a: Int = 100; { val a: Int = 0; ((c: Int) => c).apply(a) }

The problem does not appear if one uses 'apply', as in:

val a = 100; { val a = 0; (c: Int) => c } apply a
@scabug
Copy link
Author

scabug commented Feb 2, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10170?orig=1
Reporter: Lionel Parreaux (LPTK)
Affected Versions: 2.11.8, 2.12.1
Duplicates #7881

@scabug
Copy link
Author

scabug commented Feb 3, 2017

@SethTisue said:
great catch!! can't believe this went unnoticed for so long. (it's been broken at least since 2.7, perhaps since the dawn of Scala time.)

@scabug
Copy link
Author

scabug commented Feb 3, 2017

@odersky said (edited on Feb 3, 2017 11:39:56 AM UTC):
That's indeed embarrassing. Should have an easy fix. For what it's worth, dotty does not have that problem.

@scabug
Copy link
Author

scabug commented Feb 10, 2017

@som-snytt said (edited on Feb 10, 2017 9:51:14 PM UTC):
And just when you think, Who would ever do that?

And what would paulp quip if he were still quipping on tickets?

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