www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23915] New: Instance method properties not evaluated when

https://issues.dlang.org/show_bug.cgi?id=23915

          Issue ID: 23915
           Summary: Instance method properties not evaluated when passed
                    to template value argument
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

//////////////////////////// test.d ///////////////////////////
template T(bool value) {}

                    property bool getValue() { return true; }
alias Inst1 = T!(getValue); // OK

struct S2 { static  property bool getValue() { return true; } }
alias Inst2 = T!(S2.getValue); // OK

struct S3 {         property bool getValue() { return true; } }
alias Inst = T!(S3().getValue); // Error
///////////////////////////////////////////////////////////////

For some reason, free functions and static functions work, but not instance
methods.

Compiler says:

test.d(10): Error: template instance `T!(getValue)` does not match template
declaration `T(bool value)`
test.d(10):        `getValue` is not of a value of type `bool`

--
May 12 2023