[ nice-Bugs-1090679 ] Comparison of possibly null value with primitive value
"SourceForge.net" <[email protected]> Thu, 10 Feb 2005 18:12:01 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1090679, was opened at 2004-12-24 04:03
Message generated for change (Comment added) made by bonniot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090679&group_id=12788
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: mike.beckerle (mbeckerle)
>Assigned to: Daniel Bonniot (bonniot)
>Summary: Comparison of possibly null value with primitive value
Initial Comment:
I have a runtime error that should be a type error at
compile time:
package bug1;
(?int, int) foo(byte by, int pos) {
if ((by & 0x80) == 0x80) {
return (null, pos);
}
return (by, pos);
}
void _test_foo() {
var ?int charcode = null;
var int pos = 0;
var res = foo(65, 0);
(charcode, pos) = res;
println(charcode); //prints 65
// assert(charcode != null);
assert(charcode == 65); // Fails, at run time. Succeeds
if above assert is not commented out.
// assert(charcode == new java.lang.Integer(65)); //
also fails same way
// I think the above should fail to typecheck at compile
time since ?int == int should fail to check.
assert(pos == 0);
}
----------------------------------------------------------------------
>Comment By: Daniel Bonniot (bonniot)
Date: 2005-02-11 03:12
Message:
Logged In: YES
user_id=88952
I just commited the fix to CVS. The development version
should include it now.
In your example, the assertion will not fail anymore, as
'charcode == 65' now returns true.
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2004-12-24 14:37
Message:
Logged In: YES
user_id=88952
Thanks for the report, we're going to look into this.
At the moment, I rather think that ?int == int makes sense
typing wise. The values can be equal, so the test is useful.
The problem is with the way the code is generated, and we
will change it to make it give the right result.
Cheers.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090679&group_id=12788
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click