Skip to content

Commit c6d1a03

Browse files
committed
fix expected string length bug
1 parent 9add4b5 commit c6d1a03

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pegged/peg.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -1656,15 +1656,15 @@ template or(rules...) if (rules.length > 0)
16561656
failedLength[i] = temp.end;
16571657
if (temp.end >= longestFail.end)
16581658
{
1659+
if (temp.end == longestFail.end)
1660+
errorStringChars += (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4;
1661+
else
1662+
errorStringChars = (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4;
16591663
maxFailedLength = temp.end;
16601664
longestFail = temp;
16611665
names[i] = errName;
16621666
results[i] = temp;
16631667
1664-
if (temp.end == longestFail.end)
1665-
errorStringChars += (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4;
1666-
else
1667-
errorStringChars = (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4;
16681668
}
16691669
// Else, this error parsed less input than another one: we discard it.
16701670
}

0 commit comments

Comments
 (0)