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

IllegalArgumentException creating Array[Array[Unit]] #5680

Closed
scabug opened this issue Apr 18, 2012 · 3 comments
Closed

IllegalArgumentException creating Array[Array[Unit]] #5680

scabug opened this issue Apr 18, 2012 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 18, 2012

in both 2.9 and trunk,

scala> Array.fill(1)(Array(()))
java.lang.IllegalArgumentException
	at java.lang.reflect.Array.newArray(Native Method)
	at java.lang.reflect.Array.newInstance(Array.java:52)
	at scala.reflect.ClassManifest$class.arrayClass(ClassManifest.scala:107)
	at scala.reflect.Manifest$$anon$9.arrayClass(Manifest.scala:152)
	at scala.reflect.Manifest$class.arrayManifest(Manifest.scala:46)
	at scala.reflect.Manifest$$anon$9.arrayManifest(Manifest.scala:152)
	at scala.reflect.Manifest$$anon$9.arrayManifest(Manifest.scala:152)
	at scala.reflect.ClassManifest$.arrayType(ClassManifest.scala:205)
	at .<init>(<console>:8)

I know that Array[Array[Unit]] doesn't seem useful or important, but, a friend of mine who's learning Scala actually hit this on his first day with the language. It can easily happen if you accidentally omit an equals sign in a method declaration, something like:

def foo(x: Int, y: Int) { x + y }; Array.tabulate(3, 3)(foo)
@scabug
Copy link
Author

scabug commented Apr 18, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5680?orig=1
Reporter: @SethTisue
Affected Versions: 2.9.2, 2.10.0
Other Milestones: 2.10.0-M3

@scabug
Copy link
Author

scabug commented Apr 24, 2012

@xeno-by said:
Fixed in scala/scala@be11c92

@scabug scabug closed this as completed Apr 24, 2012
@scabug
Copy link
Author

scabug commented Apr 24, 2012

@SethTisue said:
awesome. thanks!

@scabug scabug added this to the 2.10.0-M2 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants