From b634a43a5ae8f9b018b84d1d514ff5f072c17c19 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 4 Nov 2019 00:49:58 +0100 Subject: [PATCH] :art: Update --- src/import/checker.c | 5 +++-- src/import/fdef.c | 2 +- tests/import/array_in_var_name.c | 18 ++++++++++++++++++ tests/import/array_incoherent_in_var_name.c | 18 ++++++++++++++++++ tests/import/array_invalid_in_var_name.c | 18 ++++++++++++++++++ tests/import/checker.c | 18 ++++++++++++++++++ 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 tests/import/array_in_var_name.c create mode 100644 tests/import/array_incoherent_in_var_name.c create mode 100644 tests/import/array_invalid_in_var_name.c create mode 100644 tests/import/checker.c diff --git a/src/import/checker.c b/src/import/checker.c index d6341ed2..b713fec3 100644 --- a/src/import/checker.c +++ b/src/import/checker.c @@ -250,6 +250,7 @@ ANN static void array_add_exp(struct array_checker *ck, const Exp exp) { } ANN m_bool _array_check(const Gwi gwi, struct array_checker *ck) { + const m_str base = ck->str; const size_t sz = strlen(ck->str); char tmp[sz + 1]; for(m_uint i = 0; i < sz; ++i) { @@ -277,9 +278,9 @@ ANN m_bool _array_check(const Gwi gwi, struct array_checker *ck) { if(isdigit(c)) tmp[i] = c; else - GWI_ERR_B(_("invalid subscript '%c' in '%s'"), c, ck->str) + GWI_ERR_B(_("invalid subscript '%c' in '%s'"), c, base) } - GWI_ERR_B(_("incoherent subscript '%s'"), ck->str) + GWI_ERR_B(_("incoherent subscript '%s'"), base) } ANN m_bool array_check(const Gwi gwi, struct array_checker *ck) { diff --git a/src/import/fdef.c b/src/import/fdef.c index ab21b7e6..53d0ef16 100644 --- a/src/import/fdef.c +++ b/src/import/fdef.c @@ -122,7 +122,7 @@ ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi, flag)) // what happens if it is in a template class ? const m_bool ret = traverse_fptr_def(gwi->gwion->env, fptr); - if(fptr->base->func) + if(fptr->base->func) // is it needed ? SET_FLAG(fptr->base->func, builtin); const Type t = ret > 0 ? fptr->type : NULL; free_fptr_def(gwi->gwion->mp, fptr); diff --git a/tests/import/array_in_var_name.c b/tests/import/array_in_var_name.c new file mode 100644 index 00000000..bc78e3ef --- /dev/null +++ b/tests/import/array_in_var_name.c @@ -0,0 +1,18 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +GWION_IMPORT(checker) { + gwi_item_ini(gwi, "int", "array[]"); + return GW_OK; +} diff --git a/tests/import/array_incoherent_in_var_name.c b/tests/import/array_incoherent_in_var_name.c new file mode 100644 index 00000000..466e25c3 --- /dev/null +++ b/tests/import/array_incoherent_in_var_name.c @@ -0,0 +1,18 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +GWION_IMPORT(checker) { + gwi_item_ini(gwi, "int", "array[2][3][]"); + return GW_OK; +} diff --git a/tests/import/array_invalid_in_var_name.c b/tests/import/array_invalid_in_var_name.c new file mode 100644 index 00000000..5538321d --- /dev/null +++ b/tests/import/array_invalid_in_var_name.c @@ -0,0 +1,18 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +GWION_IMPORT(checker) { + gwi_item_ini(gwi, "int", "array[.]"); + return GW_OK; +} diff --git a/tests/import/checker.c b/tests/import/checker.c new file mode 100644 index 00000000..33d19b2d --- /dev/null +++ b/tests/import/checker.c @@ -0,0 +1,18 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +GWION_IMPORT(checker) { + CHECK_BB(tmpl_valid(gwi, "