Skip to content

Commit bdd26d3

Browse files
committed
Prevent slicing beyond bounds.
Apply same fix as in #325. Fixes #333 ArraySliceError.
1 parent 31e02e2 commit bdd26d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pegged/peg.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ template longest_match(rules...) if (rules.length > 0)
19271927
foreach(i; 0..rules.length)
19281928
if (failedLength[i] == maxFailedLength && results[i].matches.length > 0)
19291929
errString ~= results[i].matches[$-1] ~ names[i][] ~ " or ";
1930-
orErrorString = errString[0..$-4];
1930+
orErrorString = errString[0..$ >= 4 ? $-4 : $];
19311931
19321932
longestFail.matches = longestFail.matches.length == 0 ? [orErrorString] :
19331933
longestFail.matches[0..$-1] // discarding longestFail error message

0 commit comments

Comments
 (0)