Better mixin error messages

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 18 02:40:21 PDT 2016


On 18.04.2016 00:08, Bauss wrote:
> On Sunday, 17 April 2016 at 21:59:38 UTC, Timon Gehr wrote:
>> On 17.04.2016 23:49, Bauss wrote:
>>> On Sunday, 17 April 2016 at 21:23:58 UTC, Timon Gehr wrote:
>>>> mixin(generate());
>>>> pragma(msg,generate());
>>>   That's not a solution to the problem, because you will be printing ALL
>>> mixins and not just the ones causing compilation errors.
>>
>> Obviously you'll insert this specifically for the mixin that causes
>> the compilation error.
>
> I don't think you understand the issue.

I'm giving better alternative solutions than printing the offending 
mixin at runtime. The error messages could be improved too. What 
concrete suggestions do you have? (I.e., with details.)


> It's the same mixin but with
> different parameters for the generation, thus this is not possible,
> because you don't know which one of the exact generated ones is the issue,
> ...

AFAIK, the compiler is designed to identify them unambiguously.
In any case, you might be able to do something along the following lines:

static if(!__traits(compiles,{mixin(foo(params));}){
     pragma(msg,params);
     pragma(msg,foo(params));
}


> Like I also said

(Debatable.)

> this does not apply to normal mixins but usually very
> big mixins composited of multiple mixins and template mixins.



More information about the Digitalmars-d mailing list