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

Bug 368734

Summary: NullValueException is not thrown when returning a null value from a non-nullable return of type Any
Product: z_Archived Reporter: Brian Svihovec <svihovec>
Component: EDTAssignee: Project Inbox <edt.javascriptgen-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hjiyong, jeffdouglas, jinfahua, mheitz, pharmon, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Whiteboard:
Bug Depends on: 368733    
Bug Blocks:    

Description Brian Svihovec CLA 2012-01-16 11:28:01 EST
+++ This bug was initially created as a clone of Bug #368733 +++

Given the following EGL Source:

 data Any?;
 function getData()returns(any)
    	data = null;
    	return (data);
 end

 function main()
   SysLib.writestdout(getData());
 end

A NVE is not thrown at runtime.

NOTE: An NVE is thrown if you change the type of 'data' to a 'String?' and change the return type of 'getData' to 'String' from 'any'.
Comment 1 Huang Ji Yong CLA 2012-01-18 07:07:17 EST
Defer from 0.8I1 because of vacation
Comment 2 Huang Ji Yong CLA 2012-03-30 22:43:30 EDT
Change the return type of getData() to any? will work.
It seems the problem now is that the return type is not validated. Since the return type of getData is non-nullable, we should not allow return a null type.
Comment 3 Jeff Douglas CLA 2012-06-26 16:42:43 EDT
I disagree with that assessment. The problem is not in the preventing of a null return value, but instead of the usage of that return value itself. The JS generated code is missing a call to egl.checkNull around the function invocation.

It should look like this:
egl.eglx.lang.SysLib.writeStdout(egl.eglx.lang.EString.ezeCast(egl.checkNull(this.getData()), false));

instead of this original:			egl.eglx.lang.SysLib.writeStdout(egl.eglx.lang.EString.ezeCast(this.getData(), false));


The javagen logic has numerous places in the generator that wraps the checkNullable method call around various expressions. JavaScript gen needs to implement those missing ones as well.
Comment 4 Jeff Douglas CLA 2012-07-02 10:22:20 EDT
fixed