Skip to content

Commit d81cf5a

Browse files
committed
Bit Machine: Handle wrong input during execution
Resolve old FIXME
1 parent b28935c commit d81cf5a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/bit_machine/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,14 @@ impl BitMachine {
239239
}
240240
}
241241

242+
if self.read.is_empty() != self.source_ty.is_empty() {
243+
return Err(ExecutionError::InputWrongType(self.source_ty.clone()));
244+
}
245+
242246
let mut ip = program;
243247
let mut call_stack = vec![];
244248
let mut iterations = 0u64;
245249

246-
let input_width = ip.arrow().source.bit_width();
247-
// TODO: convert into crate::Error
248-
assert!(
249-
self.read.is_empty() || input_width > 0,
250-
"Program requires a non-empty input to execute",
251-
);
252250
let output_width = ip.arrow().target.bit_width();
253251
if output_width > 0 {
254252
self.new_frame(output_width);

0 commit comments

Comments
 (0)