diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index 82e9e91..67531ae 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -159,6 +159,10 @@ public final class TypeChecker checkClassInherit(c); } + public Resolver getResolver() + { + return resolver; + } /** * Given a Container `c` this will check all @@ -200,10 +204,7 @@ public final class TypeChecker */ if(cmp(c.getName(), entity.getName()) == 0) { - string containerPath = resolver.generateName(modulle, c); - string entityPath = resolver.generateName(modulle, entity); - throw new CollidingNameException(this, c, entity); - //Parser.expect("Cannot have entity \""~entityPath~"\" with same name as container \""~containerPath~"\""); + throw new CollidingNameException(this, c, entity, c); } /** * If there are conflicting names within the current container @@ -212,10 +213,7 @@ public final class TypeChecker */ else if(findPrecedence(c, entity.getName()) != entity) { - string preExistingEntity = resolver.generateName(modulle, findPrecedence(c, entity.getName())); - string entityPath = resolver.generateName(modulle, entity); - throw new CollidingNameException(this, findPrecedence(c, entity.getName()), entity); - //Parser.expect("Cannot have entity \""~entityPath~"\" with same name as entity \""~preExistingEntity~"\" within same container"); + throw new CollidingNameException(this, findPrecedence(c, entity.getName()), entity, c); } /** * Otherwise this Entity is fine diff --git a/source/tlang/compiler/typecheck/exceptions.d b/source/tlang/compiler/typecheck/exceptions.d index d9b8ec7..2ead7b9 100644 --- a/source/tlang/compiler/typecheck/exceptions.d +++ b/source/tlang/compiler/typecheck/exceptions.d @@ -28,25 +28,31 @@ public final class CollidingNameException : TypeCheckerException */ private Entity attempted; - this(TypeChecker typeChecker, Entity defined, Entity attempted) + /** + * The Container we are in + */ + private Container c; + + this(TypeChecker typeChecker, Entity defined, Entity attempted, Container c) { super(typeChecker); this.defined = defined; this.attempted = attempted; + this.c = c; /* TODO: Set `msg` */ /* TODO: (Gogga it) Generate the error message */ if(isCollidingWithContainer()) { - string containerPath = typeChecker.getResolver().generateName(modulle, defined); - string entityPath = typeChecker.getResolver().generateName(modulle, attempted); + string containerPath = typeChecker.getResolver().generateName(typeChecker.getModule(), defined); + string entityPath = typeChecker.getResolver().generateName(typeChecker.getModule(), attempted); msg = "Cannot have entity \""~entityPath~"\" with same name as container \""~containerPath~"\""; } else { - string preExistingEntity = resolver.generateName(modulle, findPrecedence(c, entity.getName())); - string entityPath = resolver.generateName(modulle, entity); + string preExistingEntity = typeChecker.getResolver().generateName(typeChecker.getModule(), typeChecker.findPrecedence(c, attempted.getName())); + string entityPath = typeChecker.getResolver().generateName(typeChecker.getModule(), attempted); msg = "Cannot have entity \""~entityPath~"\" with same name as entity \""~preExistingEntity~"\" within same container"; } }