Thread overview
[Issue 1777] New: Allow atomic types in typeof() or improve error message
Jan 10, 2008
d-bugmail
Jan 10, 2008
Don Clugston
Jul 09, 2008
d-bugmail
January 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1777

           Summary: Allow atomic types in typeof() or improve error message
           Product: D
           Version: 2.009
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: aarti@interia.pl


Currently first assert compiles, but the second one not:

void main() {
    class A {}
    static assert(is( typeof(new A) == typeof(A)) ); // 1
    static assert(is( typeof(new int*) == typeof(int*) )); // 2
}

I propose for consistancy to:
1. Allow typeof to take also atomic types.
2. Improve error message when compiler fails. Currently:
   quicktest.d(62): found '*' when expecting '.' following 'int'
   quicktest.d(62): found ')' when expecting identifier following 'int.'
   quicktest.d(62): found ';' when expecting ')'
   quicktest.d(64): found '}' when expecting ';'
   quicktest.d(65): found 'EOF' instead of statement
   quicktest.d(65): found 'EOF' instead of statement
   quicktest.d(65): found 'EOF' instead of statement

Whole thread with rationale: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=10679

From user point of view there is no difference between (int*) and (A) - both
are types, so they should work with typeof.


-- 

January 10, 2008
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1777
> 
>            Summary: Allow atomic types in typeof() or improve error message
>            Product: D
>            Version: 2.009
>           Platform: PC
>         OS/Version: All
>             Status: NEW
>           Severity: enhancement
>           Priority: P2
>          Component: DMD
>         AssignedTo: bugzilla@digitalmars.com
>         ReportedBy: aarti@interia.pl
> 
> 
> Currently first assert compiles, but the second one not:
> 
> void main() {
>     class A {}
>     static assert(is( typeof(new A) == typeof(A)) ); // 1
>     static assert(is( typeof(new int*) == typeof(int*) )); // 2
> }
> 
> I propose for consistancy to:
> 1. Allow typeof to take also atomic types.
> 2. Improve error message when compiler fails. Currently:
>    quicktest.d(62): found '*' when expecting '.' following 'int'
>    quicktest.d(62): found ')' when expecting identifier following 'int.'
>    quicktest.d(62): found ';' when expecting ')'
>    quicktest.d(64): found '}' when expecting ';'
>    quicktest.d(65): found 'EOF' instead of statement
>    quicktest.d(65): found 'EOF' instead of statement
>    quicktest.d(65): found 'EOF' instead of statement 
> 
> Whole thread with rationale:
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=10679
>

> From user point of view there is no difference between (int*) and (A) - both
> are types, so they should work with typeof.

I think this is the same as issue 1341.

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


clugdbug@yahoo.com.au changed:

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




------- Comment #2 from clugdbug@yahoo.com.au  2008-07-09 07:20 -------


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


--