fix a compiler bug of []

This commit is contained in:
blueloveTH 2023-09-24 19:35:40 +08:00
parent e097313c8f
commit c0866022fb
2 changed files with 14 additions and 1 deletions

View File

@ -392,6 +392,7 @@ namespace pkpy{
// a[<0> <state:1> : state<3> : state<5>]
int state = 0;
do{
match_newlines_repl();
switch(state){
case 0:
if(match(TK(":"))){
@ -439,6 +440,7 @@ namespace pkpy{
break;
case 5: consume(TK("]")); goto __SUBSCR_END;
}
match_newlines_repl();
}while(true);
__SUBSCR_END:
if(is_slice){

View File

@ -83,4 +83,15 @@ assert b == [1, 2, 3, 4, 5]
a = []
b = [*a, 1, 2, 3, *a, *a]
assert b == [1, 2, 3]
assert b == [1, 2, 3]
assert b[
1
] == 2
assert b[0
] == 1
assert b[0] == 1
assert b[
0] == 1