Made class name constraints good. You can have your duplicate names nested but not at same level

parser_exception_before
Tristan B. V. Kildaire 2021-03-30 21:29:57 +02:00
parent 16435c204e
commit e7905aace2
2 changed files with 46 additions and 11 deletions

View File

@ -313,6 +313,36 @@ public final class TypeChecker
} }
else else
{ {
/* Get the current container's parent container */
Container parentContainer = c.parentOf();
/* If c (container is Module) then it has no Parent */
if(!parentContainer)
{
if(cmp(c.getName(), clazz.getName()) == 0)
{
Parser.expect("Cannot use name of module, in use");
}
}
/* Find the name starting in upper cotainer */
Entity clazzAbove = resolveUp(parentContainer, clazz.getName());
if(!clazzAbove)
{
}
else
{
Parser.expect("Name in use abpve us, bad"~to!(string)(clazz));
}
/* If the Container's parent container is Module then we can have
/* TODO: Check that it doesn;t equal any class up the chain */
/* TODO: Exclude Module from this */
// /* Still check if there is something with our name above us */ // /* Still check if there is something with our name above us */
// Container parentContainer = c.parentOf(); // Container parentContainer = c.parentOf();

View File

@ -21,16 +21,16 @@ public ubyte k = 1;
private ubyte k2 = 1; private ubyte k2 = 1;
protected ubyte k3 = -1; protected ubyte k3 = -1;
class ooga : P class ooga : O
{ {
} }
class P : ooga class O : ooga
{ {
class P class I
{ {
class P : ooga class L : ooga
{ {
} }
@ -45,20 +45,25 @@ public class clazz1
int k; int k;
print("Hello world"); print("Hello world");
public class clazz1 public class clazz3
{ {
class clazz1 class bruh2
{ {
} }
} }
} }
class myModule
{
}
class bruh class bruh
{ {
class L class bruh1
{ {
class bruh class bruh2
{ {
} }
@ -67,15 +72,15 @@ class bruh
class clazz2 : bruh class clazz2 : bruh
{ {
class clazz2 class clazzU
{ {
} }
class clazz1 class clazz12
{ {
int j; int j;
private class clazz_2_2_1 : bruh, bruh2 private class clazz_2_2_1 : bruh, clazzU
{ {
} }