[ nice-Bugs-926524 ] compiler detecting tests for nullness
"SourceForge.net" <[email protected]> Wed, 31 Mar 2004 19:06:30 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #926524, was opened at 2004-03-31 16:23
Message generated for change (Comment added) made by fbarber
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=926524&group_id=12788
Category: None
Group: None
Status: Closed
Resolution: None
Priority: 5
Submitted By: Francis Barber (fbarber)
Assigned to: Nobody/Anonymous (nobody)
Summary: compiler detecting tests for nullness
Initial Comment:
The compiler complains about the following code:
String s;
s = gv.docString() != null ? gv.docString() : "null";
The error is:
The value if(`!=`(gv.docString(), null))
gv.docString()
else
"null"
cannot be assigned to s because it might be null.
However, the following code compiles fine:
void bar(?String arg) {
String s;
s = arg != null ? arg : "null";
}
Thanks,
Frank.
----------------------------------------------------------------------
>Comment By: Francis Barber (fbarber)
Date: 2004-04-01 11:06
Message:
Logged In: YES
user_id=684961
Sorry, I clearly didn't think this through properly!
Are there any issues with threads here? Is there a chance
that a variable could be altered by another thread?
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-03-31 19:24
Message:
Logged In: YES
user_id=688815
This is not a bug because the compiler doesn't know whether
the second call of gv.docString() returns the same value as
the first.
There's a feature request for this issue:
https://sourceforge.net/tracker/index.php?
func=detail&aid=671444&group_id=12788&atid=362788
In this case you can avoid the error using the 'option' or:
s = gv.docString() || "null";
this is about the same as:
let temp = gv.docString();
s = (temp != null) ? temp : "null"
Arjan
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=926524&group_id=12788
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click