[Issue 18552] std.datetime.date.Date strips year int argument to short

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 4 00:58:48 UTC 2018


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
What is the use case where this matters?

The various constructors in std.datetime accepts int in order to avoid forcing
casts when calling the constructor (especially since when it was first added to
Phobos, VRP didn't exist, so passing integer literals to a short was an error
even if they fit).

The documenattion makes it pretty clear that Date does not support values
beyond what a short can hold, and it would be highly abnormal to pass anything
which did not fit in that range. Why should Date care about checking that it
isn't given a ridiculous number for the year, especially when the result is
still a perfectly valid Date?

--


More information about the Digitalmars-d-bugs mailing list