Skip to content

Commit

Permalink
fix: Parsing race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kennarddh committed Apr 23, 2024
1 parent 32edff4 commit 7502f0c
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,18 +504,18 @@ class CommandRegistry {
val deferredCommandParameters: MutableList<Deferred<Unit>> = mutableListOf()

for (parameter in command.parametersType) {
deferredCommandParameters.add(
async {
if (!tokensIterator.hasNext()) {
if (!parameter.isOptional) {
errorMessages.add("Not enough parameter supplied. Expected ${command.parametersType.size} parameters.")
}
if (!tokensIterator.hasNext()) {
if (!parameter.isOptional) {
errorMessages.add("Not enough parameter supplied. Expected ${command.parametersType.size} parameters.")
}

return@async
}
continue
}

val token = tokensIterator.next()
val token = tokensIterator.next()

deferredCommandParameters.add(
async {
if (!parameter.isOptional && token is SkipToken) {
errorMessages.add("Parameter '${parameter.name}' is required and cannot be skipped.")
}
Expand Down

0 comments on commit 7502f0c

Please sign in to comment.