D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9127 - Error on getting `stringof` on field with body-less interface type
Summary: Error on getting `stringof` on field with body-less interface type
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-12-09 00:40 UTC by Denis Shelomovskii
Modified: 2021-04-04 22:20 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Denis Shelomovskii 2012-12-09 00:40:27 UTC
---
interface I;
struct S { I a; }
enum e = S.tupleof[0].stringof; // line 3
---

Output:
---
main.d(3): Error: function expected before (), not "module main"c of type string
---
Comment 1 Kenji Hara 2012-12-11 05:35:13 UTC
By git head, the code outputs:

----
test.d(1): Error: interface test.I is forward referenced when looking for 'stringof'
----
Comment 2 Andrej Mitrovic 2013-02-04 10:55:47 UTC
This is true for any forward declaration:

interface I;
struct S;
class C;
enum ei = I.stringof;
enum es = S.stringof;
enum ec = C.stringof;

test.d(3): Error: interface test.I is forward referenced when looking for 'stringof'
test.d(7): Error: struct S is forward referenced
test.d(5): Error: class test.C is forward referenced when looking for 'stringof'

Note that Walter has stated before that .stringof is allowed to be overriden by the user, so this might have to be closed as invalid.
Comment 3 moonlightsentinel 2021-04-04 22:20:40 UTC
Works with current master