[Issue 9055] Compiler segfaults on forward reference to auto-return member function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 4 02:00:18 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9055
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|CTFE |ice
Summary|[CTFE] Compiler segfaults |Compiler segfaults on
|on paren-free auto-return |forward reference to
|forward referenced member |auto-return member function
|function call on |
|nonexistent 'this' receiver |
--- Comment #5 from Don <clugdbug at yahoo.com.au> 2013-01-04 02:00:12 PST ---
This is not a CTFE bug. Here is an example which doesn't use CTFE, properties,
or invalid use of 'this':
---
class C
{
enum a = typeof(this.b()).init;
static auto b(){ return 0; }
}
---
If in any of these examples you replace this.b() by simply b(), you get a
"forward reference to b" error message.
Here's a basic patch to do the same thing in this case. I'm not really happy
with it though, the errors for b() and this.b() should be generated in the same
function.
-- a/src/expression.c
+++ b/src/expression.c
@@ -929,6 +929,11 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction
*tf,
if (!tf->next && fd->inferRetType)
{
TemplateInstance *spec = fd->isSpeculative();
+ if ( fd->semanticRun < PASSsemanticdone )
+ { // We haven't run semantic() yet, eg bug 9055.
+ error(loc, "forward reference to %s", fd->toChars());
+ return Type::terror;
+ }
int olderrs = global.errors;
// If it isn't speculative, we need to show errors
unsigned oldgag = global.gag;
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list