From 8a322726603630833ab55b5b2727fdde4cf2d2af Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Thu, 1 Apr 2021 14:38:11 +0200 Subject: [PATCH] WIP --- source/tlang/compiler/compiler.d | 15 ++++++++++++++- source/tlang/compiler/typecheck/exceptions.d | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/tlang/compiler/compiler.d b/source/tlang/compiler/compiler.d index 6d5ce391..4b77f130 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 3ad89e4b..d9b8ec77 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()