www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1777] New: Allow atomic types in typeof() or improve error message

reply d-bugmail puremagic.com writes:
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.


-- 
Jan 10 2008
next sibling parent Don Clugston <dac nospam.com.au> writes:
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.
Jan 10 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1777


clugdbug yahoo.com.au changed:

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







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


-- 
Jul 09 2008