Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368734 - NullValueException is not thrown when returning a null value from a non-nullable return of type Any
Summary: NullValueException is not thrown when returning a null value from a non-nulla...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 368733
Blocks:
  Show dependency tree
 
Reported: 2012-01-16 11:28 EST by Brian Svihovec CLA
Modified: 2017-02-23 14:16 EST (History)
6 users (show)

See Also:


Attachments

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