Skip to content

Commit

Permalink
vm: fix collecting position of captured nodes
Browse files Browse the repository at this point in the history
There were instances of this issue in both transforming a string into
a vector of Chars (run_str) and when returning a tagged error node.
  • Loading branch information
clarete committed Oct 2, 2023
1 parent a0d4548 commit 98572a4
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions langlang_lib/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ impl<'a> VM<'a> {
.enumerate()
.map(|(i, c)| {
let start = Position::new(i, line, column);
let end = Position::new(i + 1, line, column);
let end = Position::new(i + 1, line, column + 1);
column += 1;
if c == '\n' {
column = 0;
Expand Down Expand Up @@ -865,8 +865,7 @@ impl<'a> VM<'a> {
let label = self.program.identifier(address);
let message = self.program.label_message(label_id);
let start = Position::new(frame.cursor, frame.line, frame.column);
let end = Position::new(self.cursor, 0, 0);
let span = Span::new(start, end);
let span = Span::new(start, self.pos());
self.capture(value::Error::new_val(span, label, message))?;
return Ok(());
}
Expand Down Expand Up @@ -916,12 +915,6 @@ impl<'a> VM<'a> {
let values = capframe.values.drain(..capframe.index).collect();
capframe.values.clear();
self.capture_flatten(address, values)?;

// if capframe.index > 0 {
// let values: Vec<_> = capframe.values.drain(..capframe.index).collect();
// capframe.values.clear();
// self.capture_flatten(address, values)?;
// }
self.dbg_captures()?;
Ok(())
}
Expand Down

0 comments on commit 98572a4

Please sign in to comment.