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

Bug 368735

Summary: Missing validation when returning a null literal to a non-nullable function return of type any
Product: z_Archived Reporter: Brian Svihovec <svihovec>
Component: EDTAssignee: Project Inbox <edt.compiler-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mheitz, pharmon, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Brian Svihovec CLA 2012-01-16 11:30:06 EST
Given the following EGL Source:

function getData()returns(any)
    	return (null);
    end

No validation message is reported to indicate that null can't be returned through a non-nullable return type.
Comment 1 Paul Harmon CLA 2012-02-23 12:50:17 EST
I have added the missing validation for passing a null to a non-nullable parm. I also added validation for the return statement, so that a function that is defined as returning a non-nullable cannot return a null literal.

The following were changed:

DefaultProblemRequestor
IProblemRequestor
EGLValidationResources.properties
FunctionArgumentValidator
ReturnStatementValidator
Comment 2 Brian Svihovec CLA 2012-02-23 13:23:51 EST
What is our general philosophy for validating literals?  Since we can't validate code that uses non-literals, I believe we have avoided validating literals in the past as well?
Comment 3 Paul Harmon CLA 2012-02-24 10:34:35 EST
The validation may be a bit inconsistant, but there is precidence for checking literal values.
Comment 4 Matt Heitz CLA 2012-02-24 10:38:30 EST
I think we should try to find as many errors as possible at compile time.
Comment 5 Brian Svihovec CLA 2012-04-02 13:09:00 EDT
Verified in Version: 0.8.0.v201203300902-1DV-FjuJ6QMOF4nynxT88h8G.