Bug 735 – forward reference to type Object??

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-24T19:54:00Z
Last change time
2014-02-15T13:20:21Z
Assigned to
bugzilla
Creator
davidl

Comments

Comment #0 by davidl — 2006-12-24T19:54:16Z
testmain.d import modulefault; interface ITestClass { void callable(); } void main() { auto testLibrary = new testclass; auto testCtor = testLibrary.getCtor!(ITestClass,"test.testmodule.TestClass")(); } modulefault.d struct mystruct { char[] mystring; void opCall(char[] hello) { mystring = hello; } public void* address; } class testclass{ template getCtor(TInterface, char[] classname,T...) { static ClassInfo typeClass; static Object function (T, Object) rawCtor; static TInterface internalCtor(T t) { auto a = _d_newclass(typeClass); rawCtor(t, a); return cast(TInterface)a; } TInterface function(T) getCtor() { typeClass = getClassInfo!(classname)(); char[] localchar; foreach(a;T) { localchar~=a.mangleof; } rawCtor = cast(Object function (T, Object)) getSymbol( "_D" ~ mangleSymbolName!(classname) ~ mangleSymbolName!("_ctor") ~ "F" ~ localchar ~ "ZC" ~ mangleSymbolName!(classname)).address; return &internalCtor; } } template getClassInfo(char[] classname){ ClassInfo getClassInfo(){ return cast(ClassInfo)getSymbol("__Class_").address; } } mystruct getSymbol(char[] hello) { return mystruct(hello); } } notice: any grammar mistake in getClassInfo would still trigger this segfault so i guess the problem is in the parser
Comment #1 by thomas-dloop — 2006-12-25T09:55:21Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-12-25: > http://d.puremagic.com/issues/show_bug.cgi?id=735 <snip> > notice: any grammar mistake in getClassInfo would still trigger this segfault > so i guess the problem is in the parser David please follow the common bug reporting guidelines outlined at http://www.digitalmars.com/bugs.html and http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReports reducing your code results in 4 lines that reliable reproduce the bug: # # template getCtor(T...){ # void function(T, int) x; # } # # mixin getCtor!(); # Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFkAASLK5blCcjpWoRArS5AJwNeMI94ctI+Q0e+/M0v0p3ys3GjgCfSDEj QHvJb7IGw1n7rs4BlfqPF74= =/l+x -----END PGP SIGNATURE-----
Comment #2 by davidl — 2006-12-26T02:02:54Z
it wouldn't be hard for stripping redundant code hard ;) i guess the following is short enough , testmain.d remains the same /*struct mystruct { char[] mystring; void opCall(char[] hello) { mystring = hello; } public void* address; }*/ class testclass{ template getCtor(TInterface, char[] classname,T...) { static ClassInfo typeClass; static Object function (T, Object) rawCtor; static TInterface internalCtor(T t) { /* auto a = _d_newclass(typeClass); rawCtor(t, a);*/ return cast(TInterface)a; } TInterface function(T) getCtor() { /* rawCtor = cast(Object function (T, Object)) getSymbol( "_D" ~ mangleSymbolName!(classname) ~ mangleSymbolName!("_ctor") ~ "F" ~ localchar ~ "ZC" ~ mangleSymbolName!(classname)).address; */ return &internalCtor; } } /* template getClassInfo(char[] classname){ ClassInfo getClassInfo(){ return cast(ClassInfo)getSymbol("__Class_").address; } } mystruct getSymbol(char[] hello) { return mystruct(hello); }*/ }
Comment #3 by davidl — 2007-02-12T20:41:14Z
err, dmd not segfault any more, but if i add the following to modulefault.d to make it compile : extern(D) Object _d_newclass(ClassInfo a); dmd throws me: modulefault.d(16): Error: forward reference to type Object modulefault.d(16): Error: cannot implicitly convert expression (a) of type objec t.Object to Object
Comment #4 by davidl — 2007-02-12T20:47:08Z
the following represents the bug : simplified case: buginawhole.d extern(D) Object _d_newclass(ClassInfo a); class testclass{ template getCtor(TInterface, char[] classname,T...) { static ClassInfo typeClass; static Object function (T, Object) rawCtor; static TInterface internalCtor(T t) { Object a = _d_newclass(typeClass); rawCtor(t, a); return cast(TInterface)a; } TInterface function(T) getCtor() { return &internalCtor; } } } interface ITestClass { void callable(); } void main() { auto testLibrary = new testclass; auto testCtor = testLibrary.getCtor!(ITestClass,"test.testmodule.TestClass")(); } modulefault.d(8): Error: forward reference to type Object modulefault.d(8): Error: cannot implicitly convert expression (a) of type object .Object to Object
Comment #5 by onlystupidspamhere — 2007-07-02T13:26:07Z
I can't reproduce any of the forward reference errors with DMD 1.018. Has this been fixed already?
Comment #6 by onlystupidspamhere — 2007-07-05T11:35:59Z
Cannot reproduce any forward reference errors so works for me.