Oops. Properly handle empty switch statements.

This commit is contained in:
Jonathan Turner 2012-05-17 13:20:15 -07:00
parent 78f02c375e
commit 025db4ce3a
2 changed files with 5 additions and 3 deletions

View File

@ -795,7 +795,7 @@ namespace chaiscript
match_value = this->children[0]->eval(t_ss); match_value = this->children[0]->eval(t_ss);
while (!breaking) { while (!breaking && (currentCase < this->children.size())) {
try { try {
if (this->children[currentCase]->identifier == AST_Node_Type::Case) { if (this->children[currentCase]->identifier == AST_Node_Type::Case) {
//This is a little odd, but because want to see both the switch and the case simultaneously, I do a downcast here. //This is a little odd, but because want to see both the switch and the case simultaneously, I do a downcast here.
@ -818,8 +818,6 @@ namespace chaiscript
breaking = true; breaking = true;
} }
++currentCase; ++currentCase;
if (currentCase == this->children.size())
breaking = true;
} }
return Boxed_Value(); return Boxed_Value();
} }

View File

@ -0,0 +1,4 @@
switch(true) { }
// We just have to get here without error for success
assert_equal(true, true);