]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix range operator
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Wed, 6 May 2020 15:56:55 +0000 (17:56 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Wed, 6 May 2020 15:56:55 +0000 (17:56 +0200)
src/emit/emit.c
src/lib/array.c
src/lib/string.c
src/parse/check.c

index 050cc97bf4094015264f282a4f440d7629b7faa1..db4fb657b8866a72b91fbacd6b7af8356650aaf2 100644 (file)
@@ -430,8 +430,8 @@ ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice* range) {
   CHECK_BB(emit_range(emit, range->range))
   const Symbol sym = insert_symbol("@slice");
   const Exp e = range->range->start ?: range->range->end;
-  struct Op_Import opi = { .op=sym, .lhs=range->base->info->type, .rhs=e->info->type,
-    .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp };
+  struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type,
+    .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp };
   CHECK_OB(op_emit(emit, &opi))
   return GW_OK;
 }
index dd78610f5627c8bd3549be93b28b18925c7eb7c0..c9b3b23904d1a491ee0b3e16acdb9ec610c43c31 100644 (file)
@@ -190,7 +190,7 @@ static OP_CHECK(opck_array_cast) {
 
 static OP_CHECK(opck_array_slice) {
   const Exp e = (Exp)data;
-  return e->d.exp_slice.base->info->type;
+  return e->info->type;
 }
 
 static inline m_bool bounds(const M_Vector v, const m_int i) {
@@ -339,7 +339,7 @@ GWION_IMPORT(array) {
   GWI_BB(gwi_oper_ini(gwi, "@Array", "@Array", NULL))
   GWI_BB(gwi_oper_add(gwi, opck_array_cast))
   GWI_BB(gwi_oper_end(gwi, "$", NULL))
-  GWI_BB(gwi_oper_ini(gwi, "nonnull @Array", "int", "int"))
+  GWI_BB(gwi_oper_ini(gwi, "int", "nonnull @Array", "int"))
   GWI_BB(gwi_oper_add(gwi, opck_array_slice))
   GWI_BB(gwi_oper_emi(gwi, opem_array_slice))
   GWI_BB(gwi_oper_end(gwi, "@slice", NULL))
index b26017d08bb523c243c7dc8f4bc4ac724391d6de..4c493a6f96d0d12bc31ee06648af9676dce792f2 100644 (file)
@@ -94,7 +94,7 @@ GWION_IMPORT(string) {
   GWI_BB(gwi_item_end(gwi,   ae_flag_const, NULL))
   GWI_BB(gwi_class_end(gwi))
 
-  GWI_BB(gwi_oper_ini(gwi, "string",  "nonnull string", "string"))
+  GWI_BB(gwi_oper_ini(gwi, "string",  "nonnull string", "nonnull string"))
   GWI_BB(gwi_oper_add(gwi, opck_const_rhs))
   GWI_BB(gwi_oper_end(gwi, "=>",      String_Assign))
 
@@ -102,7 +102,7 @@ GWION_IMPORT(string) {
   GWI_BB(gwi_oper_end(gwi, "==",       String_eq))
   GWI_BB(gwi_oper_end(gwi, "!=",       String_neq))
 
-  GWI_BB(gwi_oper_ini(gwi, "nonnull string", "int", "string"))
+  GWI_BB(gwi_oper_ini(gwi, "int", "nonnull string", "nonnull string"))
   GWI_BB(gwi_oper_end(gwi, "@slice", StringSlice))
 
   struct SpecialId_ spid = { .ck=check_funcpp, .exec=RegPushMe, .is_const=1 };
index 34e2beeb72256d22ce7d7bd31009d7d2178e039d..8a196dc02410ffa925eae41542b828e52057533b 100644 (file)
@@ -356,8 +356,8 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice* range) {
   CHECK_BO(check_range(env, range->range))
   const Symbol sym = insert_symbol("@slice");
   const Exp e = range->range->start ?: range->range->end;
-  struct Op_Import opi = { .op=sym, .lhs=range->base->info->type, .rhs=e->info->type,
-    .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp };
+  struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type,
+    .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp };
   return op_check(env, &opi);
 }