]> Nishi Git Mirror - gwion.git/commitdiff
:art: Update
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 3 Nov 2019 23:49:58 +0000 (00:49 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 3 Nov 2019 23:49:58 +0000 (00:49 +0100)
src/import/checker.c
src/import/fdef.c
tests/import/array_in_var_name.c [new file with mode: 0644]
tests/import/array_incoherent_in_var_name.c [new file with mode: 0644]
tests/import/array_invalid_in_var_name.c [new file with mode: 0644]
tests/import/checker.c [new file with mode: 0644]

index d6341ed2a86de378c4fd301102cbfcfe8ba5e57b..b713fec3d2fa14ec5043c68409501ba70577e3a7 100644 (file)
@@ -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) {
index ab21b7e66fc62e8d6907b706f2543610e7487c4b..53d0ef168155fc78c0e535815c01651d7e595ec5 100644 (file)
@@ -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 (file)
index 0000000..bc78e3e
--- /dev/null
@@ -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 (file)
index 0000000..466e25c
--- /dev/null
@@ -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 (file)
index 0000000..5538321
--- /dev/null
@@ -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 (file)
index 0000000..33d19b2
--- /dev/null
@@ -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, "<l"))
+  return GW_OK;
+}