Oops. Properly handle empty switch statements.
This commit is contained in:
		@@ -795,7 +795,7 @@ namespace chaiscript
 | 
			
		||||
 | 
			
		||||
          match_value = this->children[0]->eval(t_ss);
 | 
			
		||||
 | 
			
		||||
          while (!breaking) {
 | 
			
		||||
          while (!breaking && (currentCase < this->children.size())) {
 | 
			
		||||
            try {
 | 
			
		||||
              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.
 | 
			
		||||
@@ -818,8 +818,6 @@ namespace chaiscript
 | 
			
		||||
              breaking = true;
 | 
			
		||||
            }
 | 
			
		||||
            ++currentCase;
 | 
			
		||||
            if (currentCase == this->children.size())
 | 
			
		||||
              breaking = true;
 | 
			
		||||
          }
 | 
			
		||||
          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);
 | 
			
		||||
		Reference in New Issue
	
	Block a user