fix: review problems
This commit is contained in:
@@ -7,11 +7,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char fn_problem[256];
|
||||
|
||||
// defined in `compiler/analyzer/utility.c`
|
||||
extern fzl_type_t an_toktotype(fzl_token_t *tok);
|
||||
|
||||
fzl_an_res_t analyze_function(fzl_analyzer_t *analyzer, fzl_node_t *fn_node)
|
||||
{
|
||||
if (!analyzer)
|
||||
@@ -19,7 +14,7 @@ fzl_an_res_t analyze_function(fzl_analyzer_t *analyzer, fzl_node_t *fn_node)
|
||||
|
||||
if (!fn_node || fn_node->type != FZL_NODETYPE_FUNCTION)
|
||||
{
|
||||
an_push_error(analyzer, NULL, "node is not typeof FUNCTION");
|
||||
an_push_error(analyzer, NULL, "node is not a function");
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
@@ -63,7 +58,7 @@ fzl_an_res_t analyze_function(fzl_analyzer_t *analyzer, fzl_node_t *fn_node)
|
||||
if (strcmp(argname, "this") == 0 && i > 0)
|
||||
{
|
||||
an_push_error(analyzer, decl->token,
|
||||
"manual declaration of 'this' is not allowed");
|
||||
"manual declaration of 'this' is not allowed in methods");
|
||||
an_fin_ctx(analyzer);
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
@@ -87,10 +82,10 @@ fzl_an_res_t analyze_function(fzl_analyzer_t *analyzer, fzl_node_t *fn_node)
|
||||
{
|
||||
if (putres == FZL_SYMTABLE_RESULT_EXISTS)
|
||||
{
|
||||
snprintf(fn_problem, sizeof(fn_problem),
|
||||
snprintf(an_problem, sizeof(an_problem),
|
||||
"method '%s.%s' already has been declared", classname,
|
||||
(char *)fn_node->fn.name->value);
|
||||
an_push_error(analyzer, fn_node->token, fn_problem);
|
||||
an_push_error(analyzer, fn_node->token, an_problem);
|
||||
}
|
||||
else
|
||||
an_push_error(analyzer, fn_node->token, "failed to store method");
|
||||
@@ -111,10 +106,10 @@ fzl_an_res_t analyze_function(fzl_analyzer_t *analyzer, fzl_node_t *fn_node)
|
||||
{
|
||||
if (putres == FZL_SYMTABLE_RESULT_EXISTS)
|
||||
{
|
||||
snprintf(fn_problem, sizeof(fn_problem),
|
||||
snprintf(an_problem, sizeof(an_problem),
|
||||
"function '%s' already has been declared",
|
||||
(char *)fn_node->fn.name->value);
|
||||
an_push_error(analyzer, fn_node->token, fn_problem);
|
||||
an_push_error(analyzer, fn_node->token, an_problem);
|
||||
}
|
||||
else
|
||||
an_push_error(analyzer, fn_node->token, "failed to store function");
|
||||
|
||||
Reference in New Issue
Block a user