[Issue 17269] formattedWrite of struct with Nullable value fails

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 28 00:42:32 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17269

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
I think we're in a dilemma here since whatever choice we make there will be
inconsistencies. Nullable's get should throw (and it does) when you try to
fetch the value (1); on the other hand, formattedWrite should print nulls (2)
but when it tries to fetch the nullable (by calling get) an exception is thrown
due to statement (1). As I see it, there are 2 possibilities: either we make
Nullable's
get method return null if the value is unassigned or we specialize
formattedWrite for Nullable's (which is not a valid measure). In my opinion, it
should be on the user's account to check if the Nullable is assigned before
printing it, thus making this error a user error.

--


More information about the Digitalmars-d-bugs mailing list