From c6d1a03faae18c961bc0d6cd4f05e5973e8e29f1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Koppe Date: Wed, 5 Feb 2020 17:40:21 +0100 Subject: [PATCH] fix expected string length bug --- pegged/peg.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pegged/peg.d b/pegged/peg.d index 3a19400a..528a7bad 100644 --- a/pegged/peg.d +++ b/pegged/peg.d @@ -1656,15 +1656,15 @@ template or(rules...) if (rules.length > 0) failedLength[i] = temp.end; if (temp.end >= longestFail.end) { + if (temp.end == longestFail.end) + errorStringChars += (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4; + else + errorStringChars = (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4; maxFailedLength = temp.end; longestFail = temp; names[i] = errName; results[i] = temp; - if (temp.end == longestFail.end) - errorStringChars += (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4; - else - errorStringChars = (temp.matches.length > 0 ? temp.matches[$-1].length : 0) + errName.length + 4; } // Else, this error parsed less input than another one: we discard it. }