Skip to content

Conversation

jmdavis
Copy link
Member

@jmdavis jmdavis commented Jun 3, 2014

Compiler bugs previously returning by ref in several of std.datetime's functions. Fortunately, those bugs have been fixed (probably long since), so we can make those functions return by ref now.

@@ -6108,7 +6102,7 @@ public:

{
auto st = SysTime(DateTime(0, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999));
st += dur!"hnsecs"(52) += dur!"seconds"(-907);
(st += dur!"hnsecs"(52)) += dur!"seconds"(-907);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, code, did it silently change behavior, or is the change only a semantic/style? The "old" code used to be:

st += (dur!"hnsecs"(52) += dur!"seconds"(-907));

Correct?

If I'm not mistaken the two bits do different things, but the end result is the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should have the same result, but different functions are involved. Without the parens, the += on the right adds the two Durations, whereas with the parens, it's being added to the SysTime which is returned by ref from SysTime's +=. And because the test is supposed to be testing that the ref return on SysTime's opAssign works correctly, I added the parens to make sure that both +=s call SysTime's opAssign instead of Duration's opAssign.

@monarchdodra
Copy link
Collaborator

LGTM, just want your explanation WRT the parens.

monarchdodra added a commit that referenced this pull request Jun 3, 2014
More ref return fixes in std.datetime now that the compiler allows them.
@monarchdodra monarchdodra merged commit fda35e7 into dlang:master Jun 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants