Skip to content

Strange program with incorrect type ascription compiles #10943

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

Closed
LPTK opened this issue Dec 28, 2020 · 3 comments · Fixed by #14797
Closed

Strange program with incorrect type ascription compiles #10943

LPTK opened this issue Dec 28, 2020 · 3 comments · Fixed by #14797
Assignees

Comments

@LPTK
Copy link
Contributor

LPTK commented Dec 28, 2020

Minimized code

object T:
  class A
  val a = new A : Int
end T

@main def m =
  println(T.a)

This is with options:

scalacOptions ++= Seq(
  "-deprecation",
  "-encoding", "UTF-8",
  "-feature",
  "-unchecked",
  "-Yindent-colons",
  "-Ykind-projector",
  "-language:strict",
  "-source:3.1",
)

https://scastie.scala-lang.org/R2s6G90oTQ2ZcE6dn4ZlPg

Output

T$A@5b61791c

Expectation

Should not compile.

@odersky
Copy link
Contributor

odersky commented Dec 28, 2020

Would be good to get a solution as well! I am getting a bit tired of code obfuscation contests.

@LPTK
Copy link
Contributor Author

LPTK commented Dec 28, 2020

TBH this came up completely by accident (I was not trying to expose a problem), in my real-world code base, and I have no idea what's going on. Seems like this is a parser bug.

@bishabosha
Copy link
Member

bishabosha commented Dec 28, 2020

this only passes for me when using -Yindent-colons, the parser drops the type ascription

pweisenburger referenced this issue in pweisenburger/scala3 Mar 27, 2022
Closes lampepfl#3058
Closes lampepfl#10943
Closes lampepfl#12216
Closes lampepfl#12655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants