Bug 1777 – Allow atomic types in typeof() or improve error message

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-01-10T06:45:00Z
Last change time
2015-06-09T01:14:26Z
Assigned to
bugzilla
Creator
aarti
Depends on
1341

Comments

Comment #0 by aarti — 2008-01-10T06:45:00Z
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.
Comment #1 by aldacron — 2008-01-10T08:35:50Z
[email protected] 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: [email protected] > ReportedBy: [email protected] > > > 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.
Comment #2 by clugdbug — 2008-07-09T07:20:34Z
*** This bug has been marked as a duplicate of 1341 ***