LorettaDevs/Loretta

ArgumentOutOfRange exception when retrieving diagnostics when strings are used as statements

waneck opened this issue · 1 comments

Describe the bug
When strings are used as statements, an ArgumentOutOfRange exception is thrown when querying for diagnostics.

To Reproduce

using Loretta.CodeAnalysis.Lua;
using Loretta.CodeAnalysis;

var parseOptions = new LuaParseOptions(LuaSyntaxOptions.Lua51).WithDocumentationMode(DocumentationMode.Parse);

// parse
var lorettaAst = LuaSyntaxTree.ParseText(@"
""hello""
", parseOptions, "test.lua");

foreach (var exc in lorettaAst.GetDiagnostics()) // throws an ArgumentOutOfRange exception here
{
    Console.WriteLine(exc.ToString());
}

Expected behavior
A Diagnostic can be retrieved

Additional context
Loretta Version: Happens both on 0.2.13-nightly1 and 0.2.12

Add any other context about the problem here.