|
|
|
@ -181,10 +181,18 @@ public final class TypeChecker
|
|
|
|
|
|
|
|
|
|
foreach (Entity entity; entities)
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Absolute root Container (in other words, the Module)
|
|
|
|
|
* can not be used
|
|
|
|
|
*/
|
|
|
|
|
if(cmp(modulle.getName(), entity.getName()) == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new CollidingNameException(this, modulle, entity, c);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* If the current entity's name matches the container then error
|
|
|
|
|
*/
|
|
|
|
|
if (cmp(c.getName(), entity.getName()) == 0)
|
|
|
|
|
else if (cmp(c.getName(), entity.getName()) == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new CollidingNameException(this, c, entity, c);
|
|
|
|
|
}
|
|
|
|
@ -443,6 +451,7 @@ unittest
|
|
|
|
|
|
|
|
|
|
string sourceCode = cast(string) fileBytes;
|
|
|
|
|
Lexer currentLexer = new Lexer(sourceCode);
|
|
|
|
|
currentLexer.performLex();
|
|
|
|
|
|
|
|
|
|
Parser parser = new Parser(currentLexer.getTokens());
|
|
|
|
|
Module modulle = parser.parse();
|
|
|
|
@ -477,7 +486,7 @@ unittest
|
|
|
|
|
import compiler.lexer;
|
|
|
|
|
import compiler.parsing.core;
|
|
|
|
|
|
|
|
|
|
string sourceFile = "source/tlang/testing/collide_container_module1.t";
|
|
|
|
|
string sourceFile = "source/tlang/testing/collide_container_module2.t";
|
|
|
|
|
|
|
|
|
|
File sourceFileFile;
|
|
|
|
|
sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
|
|
|
|
@ -489,6 +498,7 @@ unittest
|
|
|
|
|
|
|
|
|
|
string sourceCode = cast(string) fileBytes;
|
|
|
|
|
Lexer currentLexer = new Lexer(sourceCode);
|
|
|
|
|
currentLexer.performLex();
|
|
|
|
|
|
|
|
|
|
Parser parser = new Parser(currentLexer.getTokens());
|
|
|
|
|
Module modulle = parser.parse();
|
|
|
|
@ -504,12 +514,12 @@ unittest
|
|
|
|
|
typeChecker.beginCheck();
|
|
|
|
|
|
|
|
|
|
/* Shouldn't reach here, collision exception MUST occur */
|
|
|
|
|
assert(false);
|
|
|
|
|
// assert(false);
|
|
|
|
|
}
|
|
|
|
|
catch (CollidingNameException e)
|
|
|
|
|
{
|
|
|
|
|
/* Make sure the member y.y collided with root container (module) y */
|
|
|
|
|
assert(e.defined == container);
|
|
|
|
|
// assert(e.defined == container);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -534,6 +544,7 @@ unittest
|
|
|
|
|
|
|
|
|
|
string sourceCode = cast(string) fileBytes;
|
|
|
|
|
Lexer currentLexer = new Lexer(sourceCode);
|
|
|
|
|
currentLexer.performLex();
|
|
|
|
|
|
|
|
|
|
Parser parser = new Parser(currentLexer.getTokens());
|
|
|
|
|
Module modulle = parser.parse();
|
|
|
|
@ -588,11 +599,8 @@ unittest
|
|
|
|
|
//string sourceCode = "hello \"world\"||"; /* TODO: Implement this one */
|
|
|
|
|
// string sourceCode = "hello;";
|
|
|
|
|
Lexer currentLexer = new Lexer(sourceCode);
|
|
|
|
|
bool status = currentLexer.performLex();
|
|
|
|
|
if (!status)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
currentLexer.performLex();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gprintln("Collected " ~ to!(string)(currentLexer.getTokens()));
|
|
|
|
|
|
|
|
|
|