Skip to content

Commit

Permalink
fix: Temporarily disallow classes with no constructors until we imple…
Browse files Browse the repository at this point in the history
…ment built-in ones
  • Loading branch information
alinalihassan committed May 24, 2022
1 parent 3675e51 commit 5096314
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/liblesma/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,15 @@ void Codegen::visit(Class *node) {
Scope->insertSymbol(structSymbol);

classSymbol = structSymbol;
auto has_constructor = false;
for (auto func: node->getMethods()) {
if (func->getName() == "new")
has_constructor = true;
visit(func);
}

for (auto funcs: node->getMethods())
visit(funcs);
if (!has_constructor)
throw CodegenError(node->getSpan(), "Class {} has no constructors", node->getIdentifier());

classSymbol = nullptr;
}
Expand Down

0 comments on commit 5096314

Please sign in to comment.