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

Wrong compiler error message with default parameters when specifying a nonexistent named parameter #4928

Closed
scabug opened this Issue Aug 19, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Aug 19, 2011

When calling a method using named arguments, if the method has an argument with a default value which is not specified, but another (nonexistent) parameter is specified, the compiler gives the error "parameter specified twice" instead of "not found". This is confusing and misleading:

scala> def x(a:Int,b:Int,c:Int,d:Int = 0) = println(a,b,c,d)
x: (a: Int, b: Int, c: Int, d: Int)Unit

scala> x(a=1,b=2,c=3)
(1,2,3,0)

scala> x(z=0,a=1,b=2,c=3)
<console>:9: error: parameter specified twice: a
       x(z=0,a=1,b=2,c=3)
              ^

scala> x(z=1,b=2,c=3,d=4)
<console>:9: error: not found: value z
       x(z=1,b=2,c=3,d=4)
         ^
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Aug 19, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4928?orig=1
Reporter: Mario Camou (mcamou)
Affected Versions: 2.9.0, 2.9.0-1, 2.9.1
See #4876

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Aug 19, 2011

@hubertp said:
I will take it, errors took a couple of weeks of my life already so yet another bug wouldn't make a difference.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 18, 2012

@lrytz said:
better error message since scala/scala@3c79caa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment