Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364519 - String + operator does not throw a NVE
Summary: String + operator does not throw a NVE
Status: CLOSED FIXED
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-22 15:59 EST by Brian Svihovec CLA
Modified: 2017-02-23 14:18 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 2011-11-22 15:59:17 EST
Given the following EGL Source:

decimalType decimal?;
syslib.writeStdout("decimalType " + decimalType);

The following is printed at runtime for Java:

decimalType 


The + operator for EString does not support null values:

/**
 * {@Operation +} Concatenates two strings.
 */
static function $Plus(lvalue EString in, rvalue EString in) returns(EString)
{@Operation{"+"}};

I believe this should throw an NVE at runtime.
Comment 1 Huang Ji Yong CLA 2011-12-27 01:34:23 EST
Add Jeff to CCList, because JavaGen also has this problem.
I think the problem is int the Decimal? to String conversion, NPV should be thrown in the conversion.
Comment 2 Huang Ji Yong CLA 2011-12-27 02:35:07 EST
Hi Jeff,
I think the problem should be in the reorg process.
In the following egl code:
syslib.writeStdout("decimalType " + decimalType);

decimalType is reorged to an AsExpression whose isNullable is true. I think it should be false.
Comment 3 Brian Svihovec CLA 2012-01-09 16:21:49 EST
Jeff,

I talked with Tim about this, and he agrees that an NVE should be thrown for this code.  Do you agree w/ Ji Yong's assessment in comment 1 or 2?
Comment 4 Jeff Douglas CLA 2012-01-09 17:23:53 EST
It's not so simple. This boils down to an asString operation. I think we should be consistent. There are also asInt, asDecimal, etc etc ... should these all handle this in the same way? I thinks they should, but that would also mean that concatenating anything to a string will always throw a NVE. If that is acceptable, then fine, but I don't believe that is really what is wanted.
Comment 5 Huang Ji Yong CLA 2012-01-09 21:07:23 EST
(In reply to comment #4)
> It's not so simple. This boils down to an asString operation. I think we should
> be consistent. There are also asInt, asDecimal, etc etc ... should these all
> handle this in the same way? I thinks they should, but that would also mean
> that concatenating anything to a string will always throw a NVE. If that is
> acceptable, then fine, but I don't believe that is really what is wanted.

Hi Jeff,
Is it possible to differentiate asUnNullableString() and asNullableString?
The same for the other types.
Comment 6 Brian Svihovec CLA 2012-01-11 15:37:12 EST
I talked with Matt about this issue, and he believes that the ESTRING PLUS and CONCAT operators were defined before we fully understood how nulls would work in EDT, and that we should add '?' to the parameters of these function signatures so that a null value is converted to "" at runtime.

Paul Harmon, can you update the EString signature and rebuild the EGLAR?
Comment 7 Paul Harmon CLA 2012-01-12 14:33:42 EST
I have updated EString.egl and rebuilt the eglar
Comment 8 Brian Svihovec CLA 2012-01-16 21:59:37 EST
Verified in 0.8.0.v201201120902-1CT-Fiv5_M5_LM5fUa4