www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23278] New: Can't pass alias member to a function


          Issue ID: 23278
           Summary: Can't pass alias member to a function
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: msnmancini hotmail.com

This trivial code fails to compile with the error message: 
`onlineapp.Test2.mxString!(oops).mxString` need `this` to access member

class Test2
    string oops;
enum mxString(alias c)()
    return "";

This should compile as there is no dependent usage on "this". Plus, the message
is obviously wrong as there is no member named `mxString`.

A real use case for that is:
enum mxString(alias c)()
    return typeof(c).stringof~" "~c.stringof~c.stringof~";";
Which does not depends on "this", as some code like `mxString!(typeof(oops),
oops.stringof)` would work.

Mixin template does not have this limitation, so, I believe a normal function
should not too.

Jul 31 2022