From fbb811fd4d5ee27ef030cda528c5e3992d023fbc Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Sun, 15 Sep 2013 19:07:05 +0000 Subject: [PATCH] Fixed range violation when an attribute declaration is not finished before EOF --- stdx/d/parser.d | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/stdx/d/parser.d b/stdx/d/parser.d index 493cf3e..974a065 100644 --- a/stdx/d/parser.d +++ b/stdx/d/parser.d @@ -1599,11 +1599,20 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; break; } if (currentIs(TokenType.colon)) + { node.attributeDeclaration = parseAttributeDeclaration(attr); + break; + } else node.attributes ~= attr; } while (moreTokens()); + if (!moreTokens) + { + error("Declaration expected"); + return null; + } + with (TokenType) switch (current.type) { case semicolon: @@ -6247,11 +6256,12 @@ private: if (suppressMessages <= 0) { ++errorCount; - auto column = index < tokens.length ? tokens[index].column : 0; - column++; - auto line = index < tokens.length ? tokens[index].line : 0; + auto column = index < tokens.length ? tokens[index].column : tokens[$ - 1].column; + auto line = index < tokens.length ? tokens[index].line : tokens[$ - 1].line; if (messageFunction is null) + { writefln("%s(%d:%d)[error]: %s", fileName, line, column, message); + } else messageFunction(fileName, line, column, message); }