# HG changeset patch # User Anders Johnsen # Date 1216738247 -7200 # Node ID 3622654278387b6e5df16f310fbf9a8573c22082 # Parent 0f38f1a0f06f919acb16a9aa20c0ad381ae2e7db Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface diff -r 0f38f1a0f06f -r 362265427838 ast/Decl.d --- a/ast/Decl.d Tue Jul 22 16:22:58 2008 +0200 +++ b/ast/Decl.d Tue Jul 22 16:50:47 2008 +0200 @@ -184,7 +184,10 @@ return myType; auto t = new DFunction(identifier); - t.returnType = env.findType(returnType.get); + if ( identifier.get == "this" ) + t.returnType = DType.Void; + else + t.returnType = env.findType(returnType.get); SmallArray!(DType) array; foreach (a; funcArgs) array ~= a.type(); diff -r 0f38f1a0f06f -r 362265427838 sema/ScopeBuilder.d --- a/sema/ScopeBuilder.d Tue Jul 22 16:22:58 2008 +0200 +++ b/sema/ScopeBuilder.d Tue Jul 22 16:50:47 2008 +0200 @@ -141,13 +141,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } } @@ -167,13 +168,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } } @@ -193,13 +195,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } } diff -r 0f38f1a0f06f -r 362265427838 tests/parser/new_1.d --- a/tests/parser/new_1.d Tue Jul 22 16:22:58 2008 +0200 +++ b/tests/parser/new_1.d Tue Jul 22 16:50:47 2008 +0200 @@ -1,24 +1,2 @@ - -class A -{ - this(long y) - { - } - - this(int y) - { - } - - int x; -} - -struct B -{ -} - -void main() -{ - B b; - long x; - A a = new A(x); -} +class A{this(int y){}int x;}struct B +{}void main(){B b;long x;A a=new A(x);} diff -r 0f38f1a0f06f -r 362265427838 tools/AstPrinter.d --- a/tools/AstPrinter.d Tue Jul 22 16:22:58 2008 +0200 +++ b/tools/AstPrinter.d Tue Jul 22 16:50:47 2008 +0200 @@ -40,9 +40,12 @@ case DeclType.FuncDecl: auto funcDecl = cast(FuncDecl)decl; printBeginLine(); - if(printAtt) printAttribute(decl.att); - printIdentifier(funcDecl.returnType); - space; + if (printAtt) printAttribute(decl.att); + if (funcDecl.identifier.get != "this") + { + printIdentifier(funcDecl.returnType); + space; + } printIdentifier(funcDecl.identifier); printFuncArgs(funcDecl); printOpenBrace();