diff --git a/source/diet/parser.d b/source/diet/parser.d index 6825748..e714596 100644 --- a/source/diet/parser.d +++ b/source/diet/parser.d @@ -700,7 +700,7 @@ private string parseIdent(in ref string str, ref size_t start, /* We could have consumed the complete string and still have elements on the stack or have ended non breakChars character. */ - if(stack.length == 0) { + if(i < str.length && stack.length == 0) { foreach(char it; breakChars) { if(str[i] == it) { size_t startC = start; @@ -714,6 +714,14 @@ private string parseIdent(in ref string str, ref size_t start, assert(false); } +unittest { // issue #75 + string foo = "(failure"; + Location loc; + size_t pos = 1; + import std.exception : assertThrown; + assertThrown!(DietParserException)(parseIdent(foo, pos, ")", loc)); +} + private Node[] parseDietWithExtensions(FileInfo[] files, size_t file_index, ref BlockInfo[] blocks, size_t[] import_stack) { import std.algorithm : all, any, canFind, countUntil, filter, find, map;