-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Dependent type is not working in Scala version 3.3.0-RC3 #17181
Comments
duplicate of #16804? |
I does seems like the same bug. I am not sure how compiler interprets between a regular parameter list compared a implicit parameter list. Also the above will compile, if the inline keyword is removed from the first parameter list |
@chungonn you can try it out in the current nightly build — |
@SethTisue I have not tried scala-cli, I only SBT instead for all my Scala work/projects. I went to the dotty site https://dotty.epfl.ch/ to pick up the nightly build - 3.3.1-RC1-bin-20230328-5c2efc5-NIGHTLY and it is still not working. Should I try to use tmr's nightly build instead? |
I tried it with scala-cli repl, it is still not working `➜ ~ scala-cli repl -S 3.3.nightly Downloading JVM temurin:17 scala> inline def foo[A](inline a: A)(fn: a.type => String): String = |
@chungonn I'm sorry, I was moving too quickly and my suggestion to try it in the nightly build was not really relevant. the resolution of #16804 is that the code in question should not compile — see Nicolas's remarks. it seems to me that your code should not compile either, unless you're trying to make a case otherwise? |
(as an aside, in the future, should you want to use a Scala 3 nightly in sbt rather than scala-cli, see the Stack Overflow link I provided — that's why I included it) |
Yes, I went to the link and saw your post. I wasn't sure how to setup in SBT for Scala 3. Then I read your notes on the use scala-cli, then I installed scala-cli and followed the instructions given. Thanks for pointing to that link though |
Yes, my code is not compiling. The case I am raising here is, the same code works for Scala 3.2.x and versions before it. Also the example I provided above shows that the argument constants. I am confused by Nicolas's remarks, He remarked that that it is a bug, and was fixed in issue #15511 . However, he followed by an example why it should not have worked, as his examples demonstrated the creating new instances of X. I my example, I used 2 singleton types "hello" and 1. I would assume that my case was incorrectly working prior to Scala 3.3.x, and now from Scala 3.3.x onwards, it is correctly not working, am I right? |
I have removed the inline keyword from the parameter list and all is compiling. I hope that rest of the app which uses the library will not have problems. Should I close this issue now? |
that is my understanding @nicolasstucki can you close the issue if you agree? |
My apologies, I was in a huge rush yesterday that I just realized my sample code was being commented out hence it was not showing i.e. showing only the last line which is the output. I have edited the issue to uncomment the sample code, it is correctly showing. |
OK, I think we can close this now. Good that it was cleared up. |
Compiler version 3.3.0-RC3 and 3.3.1-nightly version
Minimized code
The code works from Scala 3.1.x up to 3.2.2
inline def foo[A](inline a: A)(fn: a.type => String): String =
fn(a)
@main def hello() =
val x= foo("hello")( (s: "hello") => s + " world!")
println(s"x = ${x}")
val y = foo(1)((s: 1) => s + " world!")
println(s"y = ${y}")
println("hello, world")
Output
Expectation
x = hello world!
y = 1 world!
The text was updated successfully, but these errors were encountered: