Oops. Properly handle empty switch statements.
This commit is contained in:
parent
78f02c375e
commit
025db4ce3a
@ -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();
|
||||||
}
|
}
|
||||||
|
4
unittests/switch_empty.chai
Normal file
4
unittests/switch_empty.chai
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
switch(true) { }
|
||||||
|
|
||||||
|
// We just have to get here without error for success
|
||||||
|
assert_equal(true, true);
|
Loading…
x
Reference in New Issue
Block a user