D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15502 - Error: function core.time.dur!"nsecs".dur (long length) is not callable using argument types (MonoTimeImpl!cast(ClockType)0)
Summary: Error: function core.time.dur!"nsecs".dur (long length) is not callable using...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-03 02:35 UTC by Timothee Cour
Modified: 2016-01-04 11:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timothee Cour 2016-01-03 02:35:48 UTC
NOTE: This is a different bug from issue 15501, despite similar title.

$dmd_069_X -version=A -c -o- main.d
ok

dmd -version=A -c -o- main.d
Deprecation: function std.datetime.Clock.currSystemTick is deprecated - Use core.time.MonoTime.currTime instead

so after applying the recommended fix (version(B)):
dmd -version=B -c -o- main.d
Error: no property 'nsecs' for type 'MonoTimeImpl!cast(ClockType)0'



----
void test() {
  version(A){
    import std.datetime;
    auto temp=Clock.currSystemTick().nsecs() * 1e-9;
  }

  version(B){
    static import core.time;
    auto temp=core.time.MonoTime.currTime.nsecs * 1e-9;
  }
}
----
Comment 1 Timothee Cour 2016-01-03 02:37:58 UTC
EDIT:
i forgot to add 'import std.datetime;' inside version(B):

dmd -version=B -c -o- main.d
Error: function core.time.dur!"nsecs".dur (long length) is not callable using argument types (MonoTimeImpl!cast(ClockType)0)

---
void test() {
  version(A){
    import std.datetime;
    auto temp=Clock.currSystemTick().nsecs() * 1e-9;
  }

  version(B){
    import std.datetime;
    static import core.time;
    auto temp=core.time.MonoTime.currTime.nsecs * 1e-9;
  }
}

---
Comment 2 Timothee Cour 2016-01-03 03:02:16 UTC
so the following works:

core.time.MonoTime.currTime.ticks.nsecs.total!"nsecs"

therefore the deprecation message should be reflecting one to use that instead (or link to some explanation or this bug) instead of: 'Deprecation: function std.datetime.Clock.currSystemTick is deprecated - Use core.time.MonoTime.currTime instead'
Comment 3 Jonathan M Davis 2016-01-04 11:11:47 UTC
I confess that I don't understand what you're trying to do.

core.time.MonoTime.currTime.ticks.nsecs.total!"nsecs"

makes no sense at all. And doing the same thing with TickDuration would have been just as broken. currSystemTick returns the current tick of the system's monotonic clock as a TickDuration. It is _not_ a duration but a point in time (which is part of why TickDuration is being phased out - it's used both as a duration and a time point). So, converting it to nanoseconds is meaningless. And converting MonoTime to nanoseconds is just as meaningless. It would be like trying to convert 2016-01-04T12:00:07 to nanoseconds, only 2016-01-04T12:00:07 is the wall clock time not the time from the monotonic clock (which is just in ticks).

Please read the documentation for MonoTime. Based on what you're trying to do here, you do not appear to understand either TickDuration or MonoTime.