Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 12, 2012 Programming for std.log | ||||
---|---|---|---|---|
| ||||
Hey all, >From my experience implementing std.log and trying to keep it up to date with commits to Phobos. I think I have become fairly frustrated 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])) : bool) && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[1..__dollar])) : 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])) : bool) && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[1..__dollar])) : 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 |
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | 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.
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | Sounds like a candidate for a diagnostics bug report. Back-traces should be available any time a template instantiation fails. |
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | 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
> date with commits to Phobos. I think I have become fairly frustrated
> 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]))
> : bool)&& is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[1..__dollar]))
> : 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]))
> : bool)&& is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[1..__dollar]))
> : 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
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 > > 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. |
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | 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.
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | 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.
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 == 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.
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
|
February 12, 2012 Re: Programming for std.log | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jose Armando Garcia | 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
|
Copyright © 1999-2021 by the D Language Foundation