Voldemort Type Construction Error

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 15 08:59:14 PST 2016


On Friday, January 15, 2016 14:04:50 Nordlöw via Digitalmars-d-learn wrote:
> I've made progress at the helper findingSplitter at
>
> https://github.com/nordlow/justd/blob/master/substitution.d#L122
>
> I need this for implementing a new Phobos lazy `substitute()` (or
> replace).
>
> I've done most logic (AFAICT in my head) but I can't make the
> call to Result() work as it fails as
>
> substitution.d(187,18): Error: struct
> substitution.findingSplitter!("a == b", string, string, string,
> string).findingSplitter.Result cannot deduce function from
> argument types !()(string, string, string, string), candidates
> are:
> substitution.d(126,12):        substitution.findingSplitter!("a
> == b", string, string, string, string).findingSplitter.Result()
> substitution.d(194,32): Error: template instance
> substitution.findingSplitter!("a == b", string, string, string,
> string) error instantiating
> substitution.d(196,12): Error: undefined identifier 'equal', did
> you mean alias 'Unqual'?
> /home/per/Work/justd/traits_ex.d(64,13): Warning: statement is
> not reachable
>
> What have I missed?

Well, the last error is caused by not import equal in that code (since the
imports that would import it are local imports elsewhere in the module).

As for the main error, you have parens on the declaration of Result.

    static struct Result()

I don't know why you put them there, since Result is already effectively
templated by being inside of a templated function, and having it requires
that Result than have !() as a template argument when you're constructing
it. So, I'd say that you should just remove the parens - or if you have a
good reason that I can't think of which makes it make sense to put the
parens on Result, then you'll need to use !() when constructing it.

In any case, having the parens there but not using !() when constructing the
Result is what gives you the error you're seeing. If you remove the parens,
you get something more like

substitution.d(159): Error: template instance hasSlicing!R template 'hasSlicing' is not defined
substitution.d(160): Error: template instance hasLength!R template 'hasLength' is not defined
substitution.d(176): Error: static assert  "Handle R without slicing"
substitution.d(195):        instantiated from here: findingSplitter!("a == b", string, string, string, string)

Adding the appropriate imports results in something along the lines of

substitution.d(177): Error: static assert  "Handle R without slicing"
substitution.d(196):        instantiated from here: findingSplitter!("a == b", string, string, string, string)

Beyond that, I'd have to figure out exactly what you're up to, but it looks
like that static assert is probably there to indicate that code needs to be
added as opposed to there being another bug that needs fixing.

In any case, that should at least help you make progress.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list