diff options
Diffstat (limited to 'lib/CodeGen/ConstantGen.cc')
| -rw-r--r-- | lib/CodeGen/ConstantGen.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/CodeGen/ConstantGen.cc b/lib/CodeGen/ConstantGen.cc index e14e22f..12bf4b1 100644 --- a/lib/CodeGen/ConstantGen.cc +++ b/lib/CodeGen/ConstantGen.cc @@ -16,6 +16,10 @@ void CodeGen::emitScopedBlock(const std::vector<std::unique_ptr<StmtAST>> &Body) } bool CodeGen::prepareSymbolDeclaration(const std::string &Name, bool IsConstant) { + if (!CurrentClass.empty() && sameIdentifier(Name, "this")) { + reportError("Cannot redeclare this inside a method"); + return false; + } auto &Scope = ConstantScopes.back(); auto It = Symbols.find(Name); if (It != Symbols.end()) { |
