Bug 8450 – measureTime doesn't work with unsafe template functions
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-26T18:27:00Z
Last change time
2012-07-27T17:44:19Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2012-07-26T18:27:22Z
cat > bug.d << CODE
import std.datetime, std.stdio;
void main()
{
auto mt = measureTime!((a) {
writefln("Running tests took: %s ms", a.msecs());
})();
}
CODE
dmd bug
----
I only had a short look at this. I think the core issue is that std.traits.isSafe doesn't work for template functions.
With v2.057 isSafe used to fail silently for template functions so the unsafe measureTime overload was chosen and everything worked accidentally.
Since v2.058 isSafe will print an error but the @safe overload is selected.
Comment #1 by issues.dlang — 2012-07-26T19:35:40Z
This is a caused by bug# 8362 (that isSafe is totally broken), but the correct fix would be to have bug# 8138 fixed so that the @safety of the functions involved would be inferred. As it stands, attribute inferrence fails to solve the problem if all of the isSafe stuff is removed.
I have a pull request which fixes bug# 8362, which should be updated later today.
Comment #2 by issues.dlang — 2012-07-26T20:19:14Z
Hmmmm. I don't think that untyped lambda functions _can_ be considered @safe. They need an actual type for that to be properly checkable. They're not isCallable, and since they aren't fully formed, you can't actually know whether or not it's @safe.