Bug 11135 – Nullable(T, T nullValue) does not support NaN

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-09-28T01:05:05Z
Last change time
2017-10-03T07:30:45Z
Keywords
patch, pull
Assigned to
No Owner
Creator
Cauterite
Depends on
15316

Comments

Comment #0 by cauterite — 2013-09-28T01:05:05Z
A little unsurprising, but quite annoying. See this simple test case: void main() { import std.stdio; import std.typecons; Nullable!(float, float.nan) Value; writeln(Value.isNull, " <- should be true"); Value.nullify(); writeln(Value.isNull, " <- should be true"); }; Value.isNull always evaluates to false. A simple patch in typecons.d seems to resolve the issue, in the isNull function on line 1478, replace return _value == nullValue; with return _value is nullValue; I don't *think* this change could cause other issues, but I'm not completely certain. Tested using DMD v2.063.2 on WinXP.
Comment #1 by cauterite — 2015-11-06T09:49:36Z
Comment #2 by github-bugzilla — 2016-09-23T20:24:57Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/0efa1d3bf92bcaa6c4a99cad0b574185a537906a workaround for bug 11135 (typecons.Nullable) https://github.com/dlang/phobos/commit/bf14b1897e62f996cfbf8fc99dae9cf3476b3dfc Merge pull request #3797 from Cauterite/issue11135 Issue 11135 - Nullable(T, T nullValue) does not support NaN
Comment #3 by github-bugzilla — 2016-10-01T11:46:48Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/0efa1d3bf92bcaa6c4a99cad0b574185a537906a workaround for bug 11135 (typecons.Nullable) https://github.com/dlang/phobos/commit/bf14b1897e62f996cfbf8fc99dae9cf3476b3dfc Merge pull request #3797 from Cauterite/issue11135
Comment #4 by razvan.nitu1305 — 2017-10-03T07:30:45Z
It seems that this is a "forgot to close bug". Closing as fixed.