Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353501

Summary: Compile errors assigning numeric array literals to array fields
Product: z_Archived Reporter: Justin Spadea <jspadea>
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jeffdouglas, lasher, mheitz
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Justin Spadea CLA 2011-08-01 10:07:35 EDT
arr int[];
arr = [23]; // BAD
arr = [20000000000]; // OK
arr = [23, 20000000000]; // BAD
arr = [.1]; // OK
arr = [.1, 2]; // BAD
arr = [.1, 20000000000]; // BAD
Comment 1 Jeff Douglas CLA 2011-08-05 10:29:21 EDT
fixed
Comment 2 Justin Spadea CLA 2011-09-13 17:23:06 EDT
I'm still seeing compile errors on three of them (3rd, 5th, and 6th).
Comment 3 Jeff Douglas CLA 2011-09-13 17:37:42 EDT
Yes, and according to Matt, this is a user error. Matt says that if the user is trying to assign non-ints to an integer array, that is a user problem. Perhaps validation would be able to help.
Comment 4 Jeff Douglas CLA 2011-09-13 17:42:04 EDT
If you want me to revisit this, that would be okay, but as I recall we don't know the type of the array when the literals are being processed
Comment 5 Matt Heitz CLA 2011-09-14 09:23:29 EDT
Jeff, I'm reopening this because I'd like you to discuss it with Tim.  Decide what should happen: a validation error or a runtime error.  We shouldn't be generating code that doesn't compile for this.

Also, if we don't already have one, please open a bug for the problem where the type of an array literal is wrong.
Comment 6 Matt Heitz CLA 2011-09-15 12:13:20 EDT
Given the latest round of language changes and commandments from Tim, most of the assignment statements in this defect are invalid.  An array literal can only be assigned to a variable of exactly the same type.  I opened bug 357833 so the compiler will start rejecting the invalid stuff.
Comment 7 Justin Spadea CLA 2011-11-04 14:12:38 EDT
Changing this from invalid to fixed since it does indeed work now.