Skip to content

Commit

Permalink
Fix IndexOutOfBoundsEx in switch keyword handling
Browse files Browse the repository at this point in the history
Only affects compilation of scripts with compile errors.
  • Loading branch information
Pieter12345 committed Feb 1, 2024
1 parent 18f7a92 commit 7ee66f0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ public int process(TokenStream stream, Environment env, int keywordPosition)
// Ignore these case labels, they are being removed
caseLabels = new TreeSet<>(tokenComparator);
}
if(i + 1 > stream.size() || stream.get(i + 1).type != TType.LABEL) {
if(i + 1 >= stream.size() || stream.get(i + 1).type != TType.LABEL) {
throw new ConfigCompileException("Expected colon after default keyword",
stream.get(i + 1).target);
(i + 1 >= stream.size() ? t.target : stream.get(i + 1).target));
}
i++;
inDefault = true;
Expand Down Expand Up @@ -218,6 +218,9 @@ public int process(TokenStream stream, Environment env, int keywordPosition)
}
caseTokens.add(t);
i++;
if(i >= stream.size()) {
throw new ConfigCompileException("Incomplete case clause", t.target);
}
t = stream.get(i);
}
caseLabels.add(caseTokens);
Expand Down

0 comments on commit 7ee66f0

Please sign in to comment.