Summary: typeof(this) doesn't work outside member function
           Product: D
           Version: future
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Nick Sabalausky <> 2011-06-01 
14:30:32 PDT ---
According to
"1. typeof(this) will generate the type of what this would be in a non-static
member function, even if not in a member function. "

But this doesn't work. I have two test cases, each giving a different error
(not sure which is more useful):

Test A:
template True(T)
    immutable True = true;
struct Foo
    static assert( True!(typeof(this)) );
>dmd -c testTypeofThisA.d
testTypeofThisA.d(7): Error: this is not in a class or struct scope
testTypeofThisA.d(7): Error: 'this' is only defined in non-static member
functions, not testTypeofThisA

Test B:
struct Foo
    static assert( is(typeof(this) == Foo) );
>dmd -c testTypeofThisB.d
testTypeofThisB.d(3): Error: static assert  (is(typeof(__error) == Foo)) is

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to