Skip to content

Commit b28935c

Browse files
committed
Bit Machine: Handle empty input
Users may provide a nested product of units as input to an expression, which is technically correct. However, this will trigger a panic during execution because empty values must not take up extra frames.
1 parent 23bdebe commit b28935c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/bit_machine/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ impl BitMachine {
201201
if !input.clone().is_of_type(self.source_ty.as_ref()) {
202202
return Err(ExecutionError::InputWrongType(self.source_ty.clone()));
203203
}
204-
self.new_frame(input.len());
205-
self.write_value(&input);
206-
self.move_frame();
204+
// Unit value doesn't need extra frame
205+
if !input.is_empty() {
206+
self.new_frame(input.len());
207+
self.write_value(&input);
208+
self.move_frame();
209+
}
207210
Ok(())
208211
}
209212

0 commit comments

Comments
 (0)