Skip to content

Commit

Permalink
Ensure that "Current" token extension method returns EOF (last token)…
Browse files Browse the repository at this point in the history
… if attempting to get a token outside the range of the program list
  • Loading branch information
ethanmoffat committed Feb 3, 2022
1 parent ca470a6 commit c47ad1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions EOBot/Interpreter/Extensions/ProgramStateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public static bool MatchOneOf(this ProgramState input, params BotTokenType[] tok

public static BotToken Current(this ProgramState input)
{
if (input.ExecutionIndex >= input.Program.Count)
return input.Program[input.Program.Count - 1];

return input.Program[input.ExecutionIndex];
}
}
Expand Down

0 comments on commit c47ad1a

Please sign in to comment.