From 8567d8baeb82fee93e60ddddfd82718267855998 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Thu, 1 Apr 2021 15:26:17 +0200 Subject: [PATCH] Added recursive container check in `checkCotainer(COntainer)` on condition that current Entity being processed is a Container-typed Entity --- source/tlang/compiler/typecheck/core.d | 19 +++++++++++++++++++ source/tlang/testing/basic1.t | 9 +++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index fbe3d2d..6a65f52 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -320,6 +320,25 @@ public final class TypeChecker string entityPath = resolver.generateName(modulle, entity); Parser.expect("Cannot have entity \""~entityPath~"\" with same name as entity \""~preExistingEntity~"\" within same container"); } + /** + * Otherwise this Entity is fine + */ + else + { + string fullPath = resolver.generateName(modulle, entity); + string containerNameFullPath = resolver.generateName(modulle, c); + gprintln("Entity \""~fullPath~"\" is allowed to be defined within container \""~containerNameFullPath~"\""); + + /** + * Check if this Entity is a Container, if so, then + * apply the same round of checks within it + */ + Container possibleContainerEntity = cast(Container)entity; + if(possibleContainerEntity) + { + checkContainer(possibleContainerEntity); + } + } } diff --git a/source/tlang/testing/basic1.t b/source/tlang/testing/basic1.t index 2311670..cc7c91e 100644 --- a/source/tlang/testing/basic1.t +++ b/source/tlang/testing/basic1.t @@ -28,12 +28,17 @@ class kl class Shekshi { - class Shekshi + class Shekshi1 { } - int Shekshi; + class kl + { + + } + + int Shekshi2; class G {