diff --git a/source/tlang/compiler/compiler.d b/source/tlang/compiler/compiler.d index 6d5ce39..4b77f13 100644 --- a/source/tlang/compiler/compiler.d +++ b/source/tlang/compiler/compiler.d @@ -8,6 +8,7 @@ import compiler.parsing.core; import compiler.symbols.check; import compiler.symbols.data; import compiler.typecheck.core; +import compiler.typecheck.exceptions; void beginCompilation(string[] sourceFiles) { @@ -47,7 +48,19 @@ void beginCompilation(string[] sourceFiles) Module modulle = parser.parse(); gprintln("Type checking and symbol resolution..."); - TypeChecker typeChecker = new TypeChecker(modulle); + // try + // { + TypeChecker typeChecker = new TypeChecker(modulle); + // } + // catch(CollidingNameException e) + // { + + // } + // catch(TypeCheckerException e) + // { + + // } + // typeChecker.check(); } } \ No newline at end of file diff --git a/source/tlang/compiler/typecheck/exceptions.d b/source/tlang/compiler/typecheck/exceptions.d index 3ad89e4..d9b8ec7 100644 --- a/source/tlang/compiler/typecheck/exceptions.d +++ b/source/tlang/compiler/typecheck/exceptions.d @@ -2,6 +2,7 @@ module compiler.typecheck.exceptions; import compiler.typecheck.core; import compiler.symbols.data; +import compiler.typecheck.resolution; public class TypeCheckerException : Exception { @@ -36,6 +37,18 @@ public final class CollidingNameException : TypeCheckerException /* 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); + 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); + msg = "Cannot have entity \""~entityPath~"\" with same name as entity \""~preExistingEntity~"\" within same container"; + } } public bool isCollidingWithContainer()