[Issue 1777] New: Allow atomic types in typeof() or improve error message
Don Clugston
dac at nospam.com.au
Thu Jan 10 06:34:38 PST 2008
d-bugmail at 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 at digitalmars.com
> ReportedBy: aarti at 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.
More information about the Digitalmars-d-bugs
mailing list