Skip to content

mixin templates cannot produce opDispatch or opBinary overloads with multiple mixins #21429

Closed
@benjones

Description

@benjones
import std.stdio;


mixin template OD(string s){
 
    void opDispatch(string name)() if(name == s){
        writeln("op dispatch for ", name);
    }	
}

struct T {
    mixin OD!"x";
    mixin OD!"y";
}

struct U {
    mixin OD!"z";   
}


void main(){

    T t;
    //t.x(); //error!
    //t.y(); //error!
    t.opDispatch!"x";
    t.opDispatch!"y";
    
    U u;
    u.z(); //OK
}

The fact that explicitly calling opDispatch works for T but that the dispatches themselves don't work makes this seems like a simple oversight rather than a necessary limitation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions