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

Bug 363013

Summary: Int can be a bool expression?
Product: z_Archived Reporter: fahua jin <jinfahua>
Component: EDTAssignee: Project Inbox <edt.compiler-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: pfyu, pharmon, svihovec
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description fahua jin CLA 2011-11-07 01:22:33 EST
Build Identifier: 0.7.0.v201111060901

I have following statements in the EGL program, the returned type of function daysDifferent is int. But our EGL compiler does not prompt any error information. If generate the code to Java, then the Java program has error compilation message; If generate the code to JavaScript, then it prints true.

        amon date = "01/01/2011";
        curDate date;
        if(amon.daysDifferent(curDate))
            syslib.writeStdout("true");
        else
            syslib.writeStdout("false");
        end

Reproducible: Always
Comment 1 fahua jin CLA 2011-11-07 01:23:24 EST
The error message for the generated Java program.

Description	Resource	Path	Location	Type
Cannot cast from int to boolean	Test2.java	/org.eclipse.edt.egl.mvc.test/generatedJava/server	line 39	Java Problem
Comment 2 Paul Harmon CLA 2011-11-07 08:54:42 EST
I have updated the following validators to prevent this:

CaseStatementValidator
IfStatementValidator
WhileStatementValidator
Comment 3 Brian Svihovec CLA 2011-11-07 08:57:07 EST
Paul,

Is there a .egl file in our system types that would indicate the lack of support for this conversion?
Comment 4 Paul Harmon CLA 2011-11-07 09:06:18 EST
You can look at EBoolean.egl (which does not contain any conversion operations), and EInt.egl, which does not contain any conversion operation that takes an EBoolean.
Comment 5 fahua jin CLA 2011-11-07 21:15:11 EST
Verified in 0.7.0.v201111060901.
Comment 6 fahua jin CLA 2011-11-07 21:16:15 EST
(In reply to comment #5)
> Verified in 0.7.0.v201111060901.

Wrong version submit, it should be 0.7.0.v201111071403