[Issue 3775] Segfault(cast.c): casting no-parameter template function using property syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 9 11:28:26 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3775



--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-02-09 11:28:25 PST ---
ROOT CAUSE: This is an interaction between IFTI and property syntax.

PATCH: At the end of CastExp::semantic, make sure that the function has a type.

Index: expression.c
===================================================================
--- expression.c    (revision 373)
+++ expression.c    (working copy)
@@ -7796,7 +7796,11 @@

     // BUG: Check for casting array types, such as void[] to int*[]
     }
-
+    if (!e1->type && e1->op==TOKdottd)
+    {
+    error("%s is a template and cannot be called with property syntax",
e1->toChars());
+    return new ErrorExp();
+    }
     e = e1->castTo(sc, to);
     return e;
 }

=====
Some similar cases cause the compiler to do strange things (see below), so I'm
not completely satisfied with the patch. But let's just fix the segfault.

struct Bug3775 {
  static int byLine()()    { return 1;   }
}
void main(){ auto xxx = Bug3775.byLine; } // accepted; xxx is an int.
void main(){ int xxx = Bug3775.byLine; } // rejected: (Bug3775).byLine() has no
value

-- 
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