Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364391 - Expect null value to get converted to default value when passed as non-nullable parameter
Summary: Expect null value to get converted to default value when passed as non-nullab...
Status: CLOSED WONTFIX
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-11-21 11:59 EST by Will Smythe CLA
Modified: 2017-02-23 14:14 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will Smythe CLA 2011-11-21 11:59:19 EST
I have the following private function declared in a library (targeted at JS):

private function createAndShowDialog(title string in,message String in, content widget in, buttons DojoButton[] in) returns(DojoDialog)

Note the message parameter is non-nullable.

I then have the following code that invokes this function. Note "null" is being passed as the message parameter:

return(createAndShowDialog(title, null, content, buttons));

This code compiles and generates, but fails at runtime with the following message:

Uncaught exception occurred during handling of undefined.onClick event
[CRRUI2005E] A null reference cannot be used.
[CRRUI2094E] Here are the EGL function calls leading to this error:

    DojoButton.DojoButton.setAttribute() [native JavaScript]


I think EGL should convert a null literal (possible null variable) passed into a non-nullable field (covert to the default value of the type, so in this example an empty string - ""). We perform other conversions (e.g. covert a literal 6 into a decimal 6 if passed into a function that expects a decimal). I don't think we necessarily "dirty up" our null story by doing this since the developer has made the conscious choice to declare the parameter as non-nullable, so they expect this parameter variable to not be null when accessed/used in the function.
Comment 1 Jeff Douglas CLA 2011-12-23 12:18:47 EST
I have prepared (but not committed) the changes to do this (setting of the default for the type) for both javaGen and javaScriptGen, however, I am not sure we want to allow this in the first place. Sure, it makes it so that a user can code the passing of a null, but if you try to do that with a regular assignment, you get a validation error.

For example:
s string;
s = null;

The above gives a validation error, so my feeling is that the passing of a null should also produce a validation error.

We need to have Tim weigh in on this, I'll hold off committing the changes until we get a decision.
Comment 2 Brian Svihovec CLA 2012-01-03 16:49:26 EST
I do not think that we should implement this for the same reason that Jeff described in comment 1:

s string;
s = null;

The language should be consistent, and the above sample does not result in s being assigned a value of "".
Comment 3 Brian Svihovec CLA 2012-01-12 13:08:19 EST
Marking as 'won't fix'.  If you still think this should be changed, please re-open and discuss the issue with Tim.
Comment 4 Will Smythe CLA 2012-02-21 10:08:58 EST
Closing based on discussion.