Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361163 - Cast missing on generated FOR statement when TO expression type does not match the index type
Summary: Cast missing on generated FOR statement when TO expression type does not matc...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-17 12:32 EDT by Paul Harmon CLA
Modified: 2017-02-23 14:14 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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