blueloveTH 2 éve
szülő
commit
ddb20d2f91
4 módosított fájl, 15 hozzáadás és 2 törlés
  1. 2 0
      src/expr.h
  2. 5 0
      src/frame.h
  3. 1 1
      src/linalg.h
  4. 7 1
      tests/99_bugs.py

+ 2 - 0
src/expr.h

@@ -65,6 +65,8 @@ struct CodeEmitContext{
         co->blocks[curr_block_i].end = co->codes.size();
         co->blocks[curr_block_i].end = co->codes.size();
         curr_block_i = co->blocks[curr_block_i].parent;
         curr_block_i = co->blocks[curr_block_i].parent;
         if(curr_block_i < 0) FATAL_ERROR();
         if(curr_block_i < 0) FATAL_ERROR();
+        // add a no op here to make block check work
+        emit(OP_NO_OP, BC_NOARG, BC_KEEPLINE);
     }
     }
 
 
     // clear the expression stack and generate bytecode
     // clear the expression stack and generate bytecode

+ 5 - 0
src/frame.h

@@ -182,6 +182,11 @@ struct Frame {
         if(_next_ip >= co->codes.size()){
         if(_next_ip >= co->codes.size()){
             while(i>=0) i = _exit_block(i);
             while(i>=0) i = _exit_block(i);
         }else{
         }else{
+            // BUG!!!
+            // for i in range(4):
+            //     _ = 0
+            // # if there is no op here, the block check will fail
+            // while i: --i
             const Bytecode& next = co->codes[target];
             const Bytecode& next = co->codes[target];
             while(i>=0 && i!=next.block) i = _exit_block(i);
             while(i>=0 && i!=next.block) i = _exit_block(i);
             if(i!=next.block) throw std::runtime_error("invalid jump");
             if(i!=next.block) throw std::runtime_error("invalid jump");

+ 1 - 1
src/linalg.h

@@ -585,7 +585,7 @@ struct PyMat3x3: Mat3x3{
                 PyVec3& other = _CAST(PyVec3&, args[1]);
                 PyVec3& other = _CAST(PyVec3&, args[1]);
                 return VAR_T(PyVec3, self.matmul(other));
                 return VAR_T(PyVec3, self.matmul(other));
             }
             }
-            vm->TypeError("unsupported operand type(s) for @");
+            vm->BinaryOptError("@");
             return vm->None;
             return vm->None;
         };
         };
 
 

+ 7 - 1
tests/99_bugs.py

@@ -47,4 +47,10 @@ assert (
 assert f((
 assert f((
     g(1),
     g(1),
     2
     2
-)) == (1, 2)
+)) == (1, 2)
+
+def f():
+    for i in range(4):
+        _ = 0
+    while i: --i
+f()