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

Contextual vararg parameters #18090

Closed
prolativ opened this issue Jun 28, 2023 · 4 comments · Fixed by #18186
Closed

Contextual vararg parameters #18090

prolativ opened this issue Jun 28, 2023 · 4 comments · Fixed by #18186
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc area:typer good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree
Milestone

Comments

@prolativ
Copy link
Contributor

Compiler version

3.3.2-RC1-bin-20230627-588a0b1-NIGHTLY and before

Minimized code

def foo(using xs: Int*) = xs
val f = foo

Output

[error] UsingVarargs.scala:2:12
[error] no implicit argument of type Int* was found for parameter xs of method foo
[error] val f = foo
[error]            ^

Expectation

There seems to be no way to define an instance of a vararg type, e.g. given Int* = 0 won't work.
Even if one defines a given instance of a corresponding non-vararg type or a type wrapped into a Seq (given Int = 0 or given Seq[Int] = Seq(0)) it won't be picked by the implicits resolution. The only way to pass such parameter seems to be foo(using 0).
Taking that into account it seems reasonable to raise a warning when a user defines a using parameter with a vararg type.

@prolativ prolativ added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc area:typer labels Jun 28, 2023
@Kordyjan Kordyjan added the good first issue Perfect for someone who wants to get started contributing label Jun 29, 2023
@nicolasstucki
Copy link
Contributor

This should be an error. The signature is non-sensical as we could find no implicit or the same one and provide it an arbitrary number of times.

@nicolasstucki
Copy link
Contributor

This should probably be checked while typing the def.

@Kordyjan
Copy link
Contributor

Kordyjan commented Jun 29, 2023

What's funny is that this function is still usable:

foo(using 1, 2, 3)

works just fine.

I agree that declarations like this are nonsensical and should be either a warning on an error.

@mbovel mbovel added the Spree Suitable for a future Spree label Jul 3, 2023
@scala-center-bot
Copy link

This issue was picked for the Issue Spree No. 33 of 11 July 2023 which takes place in 7 days. @smarter, @eugenefle, @iusildra will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc area:typer good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants