Fix crash if a block has no stats

This commit is contained in:
0x4261756D 2024-02-21 13:48:43 +01:00
parent dd813aa624
commit b7f725afee

View File

@ -423,7 +423,7 @@ class Parser
{
stats.Add(ParseStat(tokens));
}
BlockNode ret = new(stats: stats, startRegion: startRegion, endRegion: stats[^1].endRegion);
BlockNode ret = new(stats: stats, startRegion: startRegion, endRegion: (stats.Count == 0) ? startRegion : stats[^1].endRegion);
if(index < tokens.Length && tokens[index].type == TokenType.Return)
{
ret.retstat = ParseRetstat(tokens);