diff --git a/src/ast/expressions/function.cpp b/src/ast/expressions/function.cpp index d831a9e..9b21ac0 100644 --- a/src/ast/expressions/function.cpp +++ b/src/ast/expressions/function.cpp @@ -5,7 +5,7 @@ namespace ast { function_literal::function_literal(token::token token) : token(std::move(token)), - block(nullptr) {}; + body(nullptr) {}; std::string function_literal::token_literal() const { return token.literal; @@ -22,14 +22,14 @@ namespace ast { first = false; } ss << ")"; - ss << block->str(); + ss << body->str(); return ss.str(); }; function_literal::~function_literal() { for (auto& param : parameters) delete param; - if (block != nullptr) - delete block; + if (body != nullptr) + delete body; } } // namespace ast diff --git a/src/ast/expressions/function.hpp b/src/ast/expressions/function.hpp index d7958d3..1d7052c 100644 --- a/src/ast/expressions/function.hpp +++ b/src/ast/expressions/function.hpp @@ -12,7 +12,7 @@ namespace ast { function_literal(token::token); token::token token; std::vector parameters; - ast::block_stmt* block; + ast::block_stmt* body; std::string token_literal() const override; std::string str() const override; diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index f42a12c..53bb282 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -282,7 +282,7 @@ namespace parser { delete ret; return nullptr; } - ret->block = parse_block(); + ret->body = parse_block(); return ret; }; diff --git a/test/parser/function.cpp b/test/parser/function.cpp index 24caea4..2598cf8 100644 --- a/test/parser/function.cpp +++ b/test/parser/function.cpp @@ -98,9 +98,9 @@ fn () {\ CHECK(fun->parameters.size() == 0); // block - REQUIRE(fun->block->statements.size() == 1); + REQUIRE(fun->body->statements.size() == 1); ast::return_stmt* ret = - cast(fun->block->statements[0]); + cast(fun->body->statements[0]); test_boolean_literal(ret->value, true); // full string @@ -127,9 +127,9 @@ fn (x) {\ test_identifier(fun->parameters[0], "x"); // block - REQUIRE(fun->block->statements.size() == 1); + REQUIRE(fun->body->statements.size() == 1); ast::return_stmt* ret = - cast(fun->block->statements[0]); + cast(fun->body->statements[0]); test_infix_expression(ret->value, "x", "+", 1); // full string @@ -157,9 +157,9 @@ fn (x, y) {\ test_identifier(fun->parameters[1], "y"); // block - REQUIRE(fun->block->statements.size() == 1); + REQUIRE(fun->body->statements.size() == 1); ast::return_stmt* ret = - cast(fun->block->statements[0]); + cast(fun->body->statements[0]); test_infix_expression(ret->value, "x", "+", "y"); // full string @@ -192,9 +192,9 @@ let fun = fn (x, y) {\ test_identifier(fun->parameters[1], "y"); // block - REQUIRE(fun->block->statements.size() == 1); + REQUIRE(fun->body->statements.size() == 1); ast::return_stmt* ret = - cast(fun->block->statements[0]); + cast(fun->body->statements[0]); test_infix_expression(ret->value, "x", "+", "y"); // full string