fix: review problems
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_analyzer.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
|
||||
// defined in `compiler/analyzer/utility.c`
|
||||
extern bool an_is_compatible(fzl_type_t a, fzl_type_t b, char *ac, char *bc);
|
||||
#include <stdio.h>
|
||||
|
||||
// Analyze binary arithmetics
|
||||
fzl_an_res_t analyze_binmath(fzl_analyzer_t *analyzer, fzl_node_t *bin_node)
|
||||
@@ -18,7 +16,7 @@ fzl_an_res_t analyze_binmath(fzl_analyzer_t *analyzer, fzl_node_t *bin_node)
|
||||
bin_node->type != FZL_NODETYPE_POW &&
|
||||
bin_node->type != FZL_NODETYPE_MOD))
|
||||
{
|
||||
an_push_error(analyzer, NULL, "node is not typeof binary math");
|
||||
an_push_error(analyzer, NULL, "node is not binary math operator");
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
@@ -32,15 +30,19 @@ fzl_an_res_t analyze_binmath(fzl_analyzer_t *analyzer, fzl_node_t *bin_node)
|
||||
|
||||
if (left.type < FZL_TYPE_INT8)
|
||||
{
|
||||
an_push_error(analyzer, bin_node->binary_op.left->token,
|
||||
"left side is not an integer type");
|
||||
snprintf(an_problem, sizeof(an_problem),
|
||||
"integer type is expected, got '%s'",
|
||||
an_typetostr(left.type, left.classname));
|
||||
an_push_error(analyzer, bin_node->binary_op.left->token, an_problem);
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
if (right.type < FZL_TYPE_INT8)
|
||||
{
|
||||
an_push_error(analyzer, bin_node->binary_op.right->token,
|
||||
"right side is not an integer type");
|
||||
snprintf(an_problem, sizeof(an_problem),
|
||||
"integer type is expected, got '%s'",
|
||||
an_typetostr(right.type, right.classname));
|
||||
an_push_error(analyzer, bin_node->binary_op.right->token, an_problem);
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user