Browse Source

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

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

link #10
SongZihuan 4 năm trước cách đây
mục cha
commit
a2579247b6

+ 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);