Jump to page: 1 2
Thread overview
[Issue 2202] New: Error getting type of non-static member of a class
Jul 08, 2008
d-bugmail
Jul 08, 2008
d-bugmail
Jul 08, 2008
d-bugmail
Jul 08, 2008
d-bugmail
Jul 08, 2008
d-bugmail
Jul 08, 2008
d-bugmail
Jul 09, 2008
d-bugmail
Jul 09, 2008
Max Samukha
Sep 04, 2009
Don
Sep 04, 2009
Don
Oct 06, 2009
Walter Bright
July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202

           Summary: Error getting type of non-static member of a class
           Product: D
           Version: 2.015
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: samukha@voliacable.com


The following fails with 'Error: this for x needs to be type C not type int':

class C
{
    int x;
}

typeof(C.x) z;


-- 

July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202





------- Comment #1 from wbaxter@gmail.com  2008-07-08 03:51 -------
Not sure if that's really a bug or not.  I lean towards "no" since typeof is supposed to take a variable, and C.x is not a variable.

You can get what you want with typeof(C.init.x).


-- 

July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202





------- Comment #2 from samukha@voliacable.com  2008-07-08 05:16 -------
I'm not sure either as it worked before but is not mentioned in the specs. I wouldn't post it as bug if the following compiled:

static assert (!is(typeof(C.x))); // Fails with the same error, should pass
static assert (!__traits(compiles, C.x)); // Should pass

... and if this didn't compile:
struct S
{
   int x;
}

typeof(S.x) y; // Why this compiles then?

So it is either a regression or we have other bugs and inconsistencies.


-- 

July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202


davidl@126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #3 from davidl@126.com  2008-07-08 06:01 -------
in the essence, it's duplicated with bug 515

*** This bug has been marked as a duplicate of 515 ***


-- 

July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202


matti.niemenmaa+dbugzilla@iki.fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         OS/Version|Windows                     |All
           Platform|PC                          |All
         Resolution|DUPLICATE                   |




------- Comment #4 from matti.niemenmaa+dbugzilla@iki.fi  2008-07-08 09:06 -------
No, 515 is about whether .offsetof is static or not. This is about whether typeof(Class.nonstatic) should be allowed.


-- 

July 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202





------- Comment #5 from clugdbug@yahoo.com.au  2008-07-08 09:25 -------
(In reply to comment #1)
> Not sure if that's really a bug or not.  I lean towards "no" since typeof is supposed to take a variable, and C.x is not a variable.

It's supposed to take an expression. C.x is an expression.

> 
> You can get what you want with typeof(C.init.x).
> 


-- 

July 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2202





------- Comment #6 from samukha@voliacable.com  2008-07-09 00:21 -------
> It's supposed to take an expression. C.x is an expression.

C.x is not a valid expression?


-- 

July 09, 2008
<d-bugmail@puremagic.com> wrote in message news:g51hs4$rq7$1@digitalmars.com...
> http://d.puremagic.com/issues/show_bug.cgi?id=2202
>
>
>
>
>
> ------- Comment #6 from samukha@voliacable.com  2008-07-09 00:21 -------
>> It's supposed to take an expression. C.x is an expression.
>
> C.x is not a valid expression?

What's it supposed to give?  It's an instance variable.  It's syntactically an expression, but semantically it makes no sense, it has no value.

Interestingly, &C.method works.  Thankfully.  Hope that never breaks.  But that's maybe because functions are statically allocated, unlike instance variables.


July 09, 2008
On Wed, 9 Jul 2008 09:31:13 -0400, "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote:

><d-bugmail@puremagic.com> wrote in message news:g51hs4$rq7$1@digitalmars.com...
>> http://d.puremagic.com/issues/show_bug.cgi?id=2202
>>
>>
>>
>>
>>
>> ------- Comment #6 from samukha@voliacable.com  2008-07-09 00:21 -------
>>> It's supposed to take an expression. C.x is an expression.
>>
>> C.x is not a valid expression?
>
>What's it supposed to give?  It's an instance variable.  It's syntactically an expression, but semantically it makes no sense, it has no value.
>

Sometimes I just fail to express myself. I should have asked "C.x is not a valid expression, is it?", or better: "C.x is an invalid expression, isn't it?"  Or something like that.

>Interestingly, &C.method works.  Thankfully.  Hope that never breaks.  But that's maybe because functions are statically allocated, unlike instance variables.
>

I rely on &C.method too.

September 04, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2202


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au




--- Comment #7 from Don <clugdbug@yahoo.com.au>  2009-09-04 07:18:16 PDT ---
This example shows it's definitely a bug (1.047):
class C {
    int x;
}
alias C.x F;
static assert(is(typeof(F) == int)); // OK

static assert(is(typeof(C.x) == int));
//Error: static assert  (is(int == int)) is false

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2