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

Bug 361163

Summary: Cast missing on generated FOR statement when TO expression type does not match the index type
Product: z_Archived Reporter: Paul Harmon <pharmon>
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jeffdouglas
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Paul Harmon CLA 2011-10-17 12:32:35 EDT
The following EGL code produces Java that does not compile:

program pgm2 type BasicProgram {}
	
	myfloat float;  
	index int;
	
	function main()
	  
		for (index from myfloat to 10 by myFloat)
		end
	end
		
end


The generated java for the FOR looks like this:

		for (index = myfloat; index <= (short) 10; index += myfloat) {

Notice that myfloat is not cast to int before the assignment.


Even worse things happen when i change the EGL code to the following

program pgm2 type BasicProgram {}
	
	myfloat int;  
	index int;
	
	function main()
	  
		for (index from 1.0 to 10.0 by 2)
		end
	end
		
end



I have not tested this with JS gen. Please route this bug to JSGen when Java is fixed to see if the scenerios work there.
Comment 1 Jeff Douglas CLA 2011-10-19 11:10:30 EDT
fixed
Comment 2 Paul Harmon CLA 2011-11-18 09:20:59 EST
verified fix