Bug 15502 – Error: function core.time.dur!"nsecs".dur (long length) is not callable using argument types (MonoTimeImpl!cast(ClockType)0)
Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2016-01-03T02:35:00Z
Last change time
2016-01-04T11:11:47Z
Assigned to
nobody
Creator
timothee.cour2
Comments
Comment #0 by timothee.cour2 — 2016-01-03T02:35:48Z
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 by timothee.cour2 — 2016-01-03T02:37:58Z
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 by timothee.cour2 — 2016-01-03T03:02:16Z
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 by issues.dlang — 2016-01-04T11:11:47Z
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.