diff --git a/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp b/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp index ff2112b..f62e15a 100644 --- a/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp +++ b/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp @@ -60,7 +60,11 @@ namespace Porygon::Evaluation { inline void SetIndexValue(const EvalValue *key, const EvalValue* value) const final { auto index = key->EvaluateInteger(); - this->_table->at(index - 1) = value; + index--; + if (this->_table->size() <= index){ + this->_table->resize(index); + } + this->_table->at(index) = value; } [[nodiscard]] @@ -71,7 +75,7 @@ namespace Porygon::Evaluation { return _table; } - EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;; + [[nodiscard]] EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;; }; } diff --git a/src/ScriptTypes/ScriptType.hpp b/src/ScriptTypes/ScriptType.hpp index 059f311..b63bb76 100644 --- a/src/ScriptTypes/ScriptType.hpp +++ b/src/ScriptTypes/ScriptType.hpp @@ -178,6 +178,10 @@ namespace Porygon{ inline shared_ptr GetIteratorKeyType() const final{ return NumericScriptType::AwareInt; } + + [[nodiscard]] bool IsCountable() const override { + return true; + } }; }