-
Notifications
You must be signed in to change notification settings - Fork 21
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
Unary function with argument of type Unit
is not type-safe
#12495
Comments
Unit
is not type-safe
|
As annoying and un-typesafe as it is, this is perfectly legal under the current specification. SLS 6.26.1 Value Conversions
|
True, but this is under auto-tupling. I'm sure it's spec-legal to make this not compile, right? |
|
I had expected to label this "fixed in Scala 3", but I'm puzzled that Scala 3.1.0 doesn't complain, even under Closing this ticket, since it's working as designed, even though we ended up regretting the design. fwiw, I'd never write a line of Scala 2 without |
@SethTisue I also tried it twice. The spec under autotupling links to the suspended PR 4311; see also https://docs.scala-lang.org/scala3/reference/overview.html#dropped-constructs Part of that pandemic saga was linting its sister wart, multi-arg infix. I get my zigs mixed up with my zags. For this issue, perhaps a narrow lint is called for. Discarding args seems especially pernicious. |
Okay, shall we reopen it as a "help wanted" enhancement ticket? (I edited your comment slightly.) |
Thanks, I get my jigs mixed up with my jags. Oh, I had intentionally not linked the PR to avoid extra noise. Anyway, feel free to reopen. Perhaps someone will step up. BTW the other nice link there is their refusal to consider the request for "autotuple Tuple1" feature. |
In the linked PR, it warns under The value discard is triggered first. I think the message is obscure, and the second message is informative.
|
reproduction steps
using Scala
2.13.6
,problem
The compiler should not allow the arguments
("foo", "bar", "baz")
to be passed to a function that expects oneUnit
argument. This is particularly problematic for higher-order functions that may return a unaryA => Unit
function, withA
beingUnit
in situations where the first function argument is irrelevant.The text was updated successfully, but these errors were encountered: