[Issue 23915] New: Instance method properties not evaluated when passed to template value argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 12 16:43:47 UTC 2023


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 at puremagic.com
          Reporter: dlang-bugzilla at 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`

--


More information about the Digitalmars-d-bugs mailing list