Fix STRSLICE with no stop index argument (#1682)

This commit is contained in:
Rangi
2025-05-04 16:56:25 -04:00
committed by GitHub
parent 1715f85d50
commit e1ae92709c
2 changed files with 4 additions and 4 deletions

View File

@@ -1623,7 +1623,7 @@ string_literal:
| OP_STRSLICE LPAREN string COMMA iconst RPAREN {
size_t len = strlenUTF8($3, false);
uint32_t start = adjustNegativeIndex($5, len, "STRSLICE");
$$ = strsliceUTF8($3, start, len - 1);
$$ = strsliceUTF8($3, start, len);
}
| OP_STRSUB LPAREN string COMMA iconst COMMA uconst RPAREN {
size_t len = strlenUTF8($3, false);

View File

@@ -5,10 +5,10 @@ STRSLICE("ABC",-3,-2): A
STRSLICE("ABC",-2,-1): B
STRSLICE("ABC",-1,-0):
STRSLICE("ABC",-1,3): C
STRSLICE("ABC",1): B
STRSLICE("ABC",-2): B
STRSLICE("ABC",1): BC
STRSLICE("ABC",-2): BC
STRSLICE("ABC",4):
STRSLICE("ABC",-4): AB
STRSLICE("ABC",-4): ABC
STRSLICE("ABC",0,2): AB
STRSLICE("ABC",1,3): BC
STRSLICE("ABC",1,31): BC