浏览代码

fix: 修复了listiter的stopIter诱发条件

只有在indexException的时候才会诱发stopIter错误
其他错误直接返回

link #10
SongZihuan 4 年之前
父节点
当前提交
a2579247b6
共有 3 个文件被更改,包括 9 次插入1 次删除
  1. 4 1
      VirtulMathCore/ofunc/src/listiter.c
  2. 4 0
      VirtulMathCore/src/__run.c
  3. 1 0
      VirtulMathCore/src/include/__run.h

+ 4 - 1
VirtulMathCore/ofunc/src/listiter.c

@@ -54,7 +54,10 @@ ResultType listiter_next(OFFICAL_FUNCTIONSIG){
     freeResult(result);
     elementDownOne(list_, index, 0, "listiter", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!CHECK_RESULT(result))
-        setResultError(E_StopIterException, "Stop Iter", 0, "listiter", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        if (is_indexException(result->value, inter))
+            setResultError(E_StopIterException, "Stop Iter", 0, "listiter", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        else
+            return result->type;
     else {
         Result tmp_result;
         setResultCore(&tmp_result);

+ 4 - 0
VirtulMathCore/src/__run.c

@@ -360,6 +360,10 @@ bool is_iterStop(LinkValue *value, Inter *inter) {
     return value->value == inter->data.iterstop_exc->value || checkAttribution(value->value, inter->data.iterstop_exc->value);
 }
 
+bool is_indexException(LinkValue *value, Inter *inter) {
+    return value->value == inter->data.index_exc->value || checkAttribution(value->value, inter->data.index_exc->value);
+}
+
 bool checkAut(enum ValueAuthority value, enum ValueAuthority base, fline line, char *file, char *name, bool pri_auto, INTER_FUNCTIONSIG_NOT_ST) {
     if ((value == public_aut || (!pri_auto && value == auto_aut)) && (base != public_aut && base != auto_aut)) {
         if (name == NULL)

+ 1 - 0
VirtulMathCore/src/include/__run.h

@@ -34,6 +34,7 @@ ResultType getIter(LinkValue *value, int status, fline line, char *file, INTER_F
 bool checkBool(LinkValue *value, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 char *getRepoStr(LinkValue *value, bool is_repot, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 bool is_iterStop(LinkValue *value, Inter *inter);
+bool is_indexException(LinkValue *value, Inter *inter);
 bool checkAut(enum ValueAuthority value, enum ValueAuthority base, fline line, char *file, char *name, bool pri_auto, INTER_FUNCTIONSIG_NOT_ST);
 LinkValue *make_new(Inter *inter, LinkValue *belong, LinkValue *class);
 int init_new(LinkValue *obj, Argument *arg, char *message, INTER_FUNCTIONSIG_NOT_ST);