www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Programming for std.log

reply Jose Armando Garcia <jsancio gmail.com> writes:
Hey all,

From my experience implementing std.log and trying to keep it up to

with writing D programs and debugging D program compilations (specially templates). I swear that feels like every other commit breaks the std.log module. This is the latest one: std/format.d(782): Error: template std.algorithm.startsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range) && Ranges.length
 1 && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[0]))

: uint)) does not match any function template declaration std/format.d(782): Error: template std.algorithm.startsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range) && Ranges.length
 1 && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[0]))

: uint)) cannot deduce template function from argument types !()(const(char)[],char) How am I suppose to know what is wrong with std.log base on the information above in a 3000 line implementation? I don't even include std.format (as that template could have been instantiated from somewhere else). Having a lot of "experience" trying to solve this kind of problem, I normally remove all my imports and try add the symbols one at a time until I figure out what is wrong. This time I honestly think that I am stumped! I know that this is not a lot of information and I don't expect help resolving this problem but I hint this issues with the following imports: import core.sync.rwmutex: ReadWriteMutex; import std.datetime: SysTime; import std.array: Appender; Is there anyway that dmd can tell me why a template is being instantiated? Something like like: template foo instantiated from std/log.d(###) template bar instantiated from std/datetime.d(###) template startsWith instantiated from std/format.d(###) ... Thanks. Hopefully I'll figure this out sooner rather than later, -Jose
Feb 12 2012
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sunday, 12 February 2012 at 20:18:13 UTC, Jose Armando Garcia 
wrote:
 Is there anyway that dmd can tell me why a template is being
 instantiated? Something like like:

You do get that if a static assert fails. One of the first things I do when I update dmd is to hack up the source to a bunch of phobos to do something like if(!__traits(compiles, instantiation_here)) static assert(0); just because that error message is infinitely more helpful. I don't know about the std.algorithm one, but I do this in std.conv a lot and it is good there because there's a to!() entry point that then calls toImpl, and the to!() one can be easily static asserted.
Feb 12 2012
next sibling parent David Nadlinger <see klickverbot.at> writes:
On 2/12/12 11:11 PM, Adam D. Ruppe wrote:
 On Sunday, 12 February 2012 at 21:43:57 UTC, Jose Armando Garcia wrote:
 Very helpful advice! I narrowed it down to:

 $ cat format spec.d
 import std.format;
 void main() {
 static assert(is(Unqual!char == char));
 FormatSpec!char spec;
 }

 ../dmd/src/dmd -w format spec.d
 format spec.d(4): Error: static assert (is(Unqual!(char) == char)) is
 false

 This is suppose to be true, no?

It is if you import std.traits. I don't think the Unqual template is in scope there which is why the is() fails.

Could be related to the selective import (bug 314) fix, maybe std.format is missing an import or a related DMD regression was introduced. David
Feb 12 2012
prev sibling next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 02/12/2012 10:43 PM, Jose Armando Garcia wrote:
 On Sun, Feb 12, 2012 at 6:25 PM, Adam D. Ruppe
 <destructionator gmail.com>  wrote:
 On Sunday, 12 February 2012 at 20:18:13 UTC, Jose Armando Garcia wrote:
 Is there anyway that dmd can tell me why a template is being
 instantiated? Something like like:

You do get that if a static assert fails. One of the first things I do when I update dmd is to hack up the source to a bunch of phobos to do something like if(!__traits(compiles, instantiation_here)) static assert(0);

Very helpful advice! I narrowed it down to: $ cat format_spec.d import std.format; void main() { static assert(is(Unqual!char == char)); FormatSpec!char spec; } ../dmd/src/dmd -w format_spec.d format_spec.d(4): Error: static assert (is(Unqual!(char) == char)) is false This is suppose to be true, no? Thanks, -Jose

No, it should fail. You forgot to import std.traits.
Feb 12 2012
prev sibling parent David Nadlinger <see klickverbot.at> writes:
On 2/12/12 11:22 PM, Jose Armando Garcia wrote:
 Sorry for the false alarm. I think the problem went away once I
 rebuild dmd, druntime and phobos. Your advice was really good in
 helping me make any sense of this! Thanks.

 -Jose

So std.log is still/again ready for review? std.log has been in the queue forever (but was previously postponed due to Jose being unavailable), std.uuid is small (but parts of it depend on not-yet-in-Phobos hashing code), and Jacob Carlborg is waiting for feedback on Orange – no clear winner, but to finally get the process running again, I'd suggest to begin the std.log review tomorrow. Since nobody else stepped up, I'd volunteer as review manager. David
Feb 12 2012
prev sibling next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
Sounds like a candidate for a diagnostics bug report. Back-traces should 
be available any time a template instantiation fails.
Feb 12 2012
prev sibling next sibling parent Paulo Pinto <pjmlp progtools.org> writes:
Am 12.02.2012 21:18, schrieb Jose Armando Garcia:
 Hey all,

 From my experience implementing std.log and trying to keep it up to

with writing D programs and debugging D program compilations (specially templates). I swear that feels like every other commit breaks the std.log module. This is the latest one: std/format.d(782): Error: template std.algorithm.startsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range)&& Ranges.length
 1&&  is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[0]))

: uint)) does not match any function template declaration std/format.d(782): Error: template std.algorithm.startsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range)&& Ranges.length
 1&&  is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[0]))

: uint)) cannot deduce template function from argument types !()(const(char)[],char) How am I suppose to know what is wrong with std.log base on the information above in a 3000 line implementation? I don't even include std.format (as that template could have been instantiated from somewhere else). Having a lot of "experience" trying to solve this kind of problem, I normally remove all my imports and try add the symbols one at a time until I figure out what is wrong. This time I honestly think that I am stumped! I know that this is not a lot of information and I don't expect help resolving this problem but I hint this issues with the following imports: import core.sync.rwmutex: ReadWriteMutex; import std.datetime: SysTime; import std.array: Appender; Is there anyway that dmd can tell me why a template is being instantiated? Something like like: template foo instantiated from std/log.d(###) template bar instantiated from std/datetime.d(###) template startsWith instantiated from std/format.d(###) ... Thanks. Hopefully I'll figure this out sooner rather than later, -Jose

Ooch. It looks like C++ template error messages. :( -- Paulo
Feb 12 2012
prev sibling next sibling parent Jose Armando Garcia <jsancio gmail.com> writes:
On Sun, Feb 12, 2012 at 6:25 PM, Adam D. Ruppe
<destructionator gmail.com> wrote:
 On Sunday, 12 February 2012 at 20:18:13 UTC, Jose Armando Garcia wrote:
 Is there anyway that dmd can tell me why a template is being
 instantiated? Something like like:

You do get that if a static assert fails. One of the first things I do when I update dmd is to hack up the source to a bunch of phobos to do something like if(!__traits(compiles, instantiation_here)) =A0static assert(0);

Very helpful advice! I narrowed it down to: $ cat format_spec.d import std.format; void main() { static assert(is(Unqual!char =3D=3D char)); FormatSpec!char spec; } ../dmd/src/dmd -w format_spec.d format_spec.d(4): Error: static assert (is(Unqual!(char) =3D=3D char)) is = false This is suppose to be true, no? Thanks, -Jose
 just because that error message is infinitely more helpful.


 I don't know about the std.algorithm one, but I do this
 in std.conv a lot and it is good there because there's
 a to!() entry point that then calls toImpl, and the to!()
 one can be easily static asserted.

Feb 12 2012
prev sibling next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sunday, 12 February 2012 at 21:43:57 UTC, Jose Armando Garcia 
wrote:
 Very helpful advice! I narrowed it down to:

 $ cat format spec.d
 import std.format;
 void main() {
 static assert(is(Unqual!char == char));
 FormatSpec!char spec;
 }

 ../dmd/src/dmd -w format spec.d
 format spec.d(4): Error: static assert  (is(Unqual!(char) == 
 char)) is false

 This is suppose to be true, no?

It is if you import std.traits. I don't think the Unqual template is in scope there which is why the is() fails.
Feb 12 2012
prev sibling next sibling parent Jose Armando Garcia <jsancio gmail.com> writes:
On Sun, Feb 12, 2012 at 8:11 PM, Adam D. Ruppe
<destructionator gmail.com> wrote:
 On Sunday, 12 February 2012 at 21:43:57 UTC, Jose Armando Garcia wrote:
 Very helpful advice! I narrowed it down to:

 $ cat format spec.d

 import std.format;
 void main() {
 static assert(is(Unqual!char =3D=3D char));
 FormatSpec!char spec;
 }

 ../dmd/src/dmd -w format spec.d
 format spec.d(4): Error: static assert =A0(is(Unqual!(char) =3D=3D char)=


 false


 This is suppose to be true, no?

It is if you import std.traits. I don't think the Unqual template is in scope there which is why the is() fails.

Sorry for the false alarm. I think the problem went away once I rebuild dmd, druntime and phobos. Your advice was really good in helping me make any sense of this! Thanks. -Jose
Feb 12 2012
prev sibling parent Jose Armando Garcia <jsancio gmail.com> writes:
On Sun, Feb 12, 2012 at 8:32 PM, David Nadlinger <see klickverbot.at> wrote=
:
 On 2/12/12 11:22 PM, Jose Armando Garcia wrote:
 Sorry for the false alarm. I think the problem went away once I
 rebuild dmd, druntime and phobos. Your advice was really good in
 helping me make any sense of this! Thanks.

 -Jose

So std.log is still/again ready for review?

Yep! It should be. I am fixing some minor things now. Will do some final testing in Windows. Don't foresee any problems there. I will send you an email in a bit. Either way I think it should be ready for review by tomorrow!
 std.log has been in the queue forever (but was previously postponed due t=

 Jose being unavailable), std.uuid is small (but parts of it depend on
 not-yet-in-Phobos hashing code), and Jacob Carlborg is waiting for feedba=

 on Orange =96 no clear winner, but to finally get the process running aga=

 I'd suggest to begin the std.log review tomorrow. Since nobody else stepp=

 up, I'd volunteer as review manager.

 David

Feb 12 2012