← Back to index
|
Original Bugzilla link
Bug 20311 – dtext("") == null
Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-10-22T17:06:02Z
Last change time
2019-10-22T17:43:05Z
Assigned to
No Owner
Creator
Victor Porton
Comments
Comment #0
by porton — 2019-10-22T17:06:02Z
import std.conv; import std.stdio; void main() { dstring s = dtext(""); writeln(s == null); } /////////////////////// $ ldc2 x.d $ ./x true Should output "false". LDC - the LLVM D compiler (1.12.0): based on DMD v2.082.1 and LLVM 6.0.1 built with LDC - the LLVM D compiler (1.12.0) Default target: x86_64-pc-linux-gnu Host CPU: goldmont Package: libphobos2-ldc-shared82 Version: 1:1.12.0-1ubuntu1 on Ubuntu 19.04
Comment #1
by destructionator — 2019-10-22T17:23:05Z
"" == null is by design in . Use `is null` instead of `== null` for a specific check.
Comment #2
by porton — 2019-10-22T17:28:05Z
I changed it to `is null`. Still prints true. This is a bug in dtext().
Comment #3
by destructionator — 2019-10-22T17:37:29Z
The string literal "" is null is also by design in D. Why do you care about the difference btw?
Comment #4
by porton — 2019-10-22T17:43:05Z
Oh, I already have realized this myself. A few months without D programming and I forgot such basic things :-(