Skip to content
Permalink
Browse files
Fix cases where a branching implementation error is incorrectly detected
  • Loading branch information
PseudoKnight committed Jan 28, 2020
1 parent e4a5d39 commit 5fdf61ed1a67220287a30e278ecf76e2e8d502a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
@@ -2463,9 +2463,15 @@ private static boolean eliminateDeadCode(ParseTree tree, Environment env, Set<Cl
if(f instanceof BranchStatement) {
branches = ((BranchStatement) f).isBranch(children);
if(branches.size() != children.size()) {
List<Integer> numArgs = Arrays.asList(f.numArgs());
if(!numArgs.contains(Integer.MAX_VALUE) && !numArgs.contains(children.size())) {
// Incorrect number of arguments passed to the function, not a branch implementation error.
return false;
}
throw new Error(f.getName() + " does not properly implement isBranch. It does not return a value"
+ " with the same count as the actual children. Expected: " + children.size() + ";"
+ " Actual: " + branches.size() + "; Code target causing this: "
+ " with the same count as the actual children. Children: " + children.size() + ";"
+ " Branches: " + branches.size() + ";"
+ " Code target causing this: "
+ tree.getTarget());
}
} else {
@@ -209,6 +209,9 @@ public ParseTree optimizeDynamic(Target t, Environment env,

@Override
public void link(Target t, List<ParseTree> children) throws ConfigCompileException {
if(children.size() < 5) {
throw new CREInsufficientArgumentsException("bind accepts 5 or more parameters", t);
}
String name = children.get(0).getData().val();
try {
EventUtils.verifyEventName(name);

0 comments on commit 5fdf61e

Please sign in to comment.