LorettaDevs / Loretta

A C# Lua, GLua and Luau parser, code analysis, transformation and generation library.
https://loretta-oss.dev/
MIT License
119 stars 11 forks source link

ArgumentOutOfRange exception when retrieving diagnostics when strings are used as statements #126

Open waneck opened 5 months ago

waneck commented 5 months ago

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.

TheGreatSageEqualToHeaven commented 2 weeks ago

Sorry I've been busy I'll take a look at this the coming week.