Jump to specific function scope when calling function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-08 16:44:47 +02:00
parent d385a9e3ee
commit 4d452b33e0
5 changed files with 28 additions and 6 deletions

View File

@@ -80,6 +80,7 @@ BoundStatement *Binder::BindFunctionDeclarationStatement(ParsedStatement *statem
auto parameterTypes = vector<shared_ptr<ScriptType>>(parameters.size());
auto parameterKeys = vector<shared_ptr<BoundVariableKey>>(parameters.size());
auto scopeIndex = this->_scope->GetCurrentScope();
this->_scope->GoInnerScope();
for (int i = 0; i < parameters.size(); i++){
auto var = parameters[i];
@@ -97,7 +98,7 @@ BoundStatement *Binder::BindFunctionDeclarationStatement(ParsedStatement *statem
auto identifier = functionStatement->GetIdentifier();
auto returnType = make_shared<ScriptType>(TypeClass::Nil);
auto type = make_shared<FunctionScriptType>(returnType, parameterTypes, parameterKeys);
auto type = make_shared<FunctionScriptType>(returnType, parameterTypes, parameterKeys, scopeIndex);
auto assignment = this->_scope->AssignVariable(identifier.GetHash(), type);
if (assignment.GetResult() != VariableAssignmentResult::Ok){
this -> _scriptData -> Diagnostics -> LogError(DiagnosticCode::CantAssignVariable, statement->GetStartPosition(), statement->GetLength());