Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Sep 7, 2022
1 parent dc59c47 commit eeb5eb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions crates/wast/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,25 @@ impl<'a> Lexer<'a> {
// https://webassembly.github.io/spec/core/text/values.html#text-string
b'"' => {
strings += 1;

let mut it = self.remaining[pos + 1..].chars();
pos += 1;
let mut it = self.remaining[pos..].chars();
let result = Lexer::parse_str(&mut it, self.allow_confusing_unicode);
pos = self.remaining.len() - it.as_str().len();
match result {
Ok(s) => last_string_val = Some(s),
Err(e) => {
let start = self.input.len() - self.remaining.len();
self.remaining = &self.remaining[pos..];
let err_pos = self.input.len() - self.remaining.len() + pos;
let err_pos = match &e {
LexError::UnexpectedEof => self.input.len(),
_ => {
self.input[..start + pos]
.char_indices()
.next_back()
.unwrap()
.0
}
};
return Err(self.error(err_pos, e));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/wast/tests/parse-fail/bad-index.wat.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
failed to find label named `$s`
unknown label: failed to find name `$s`
--> tests/parse-fail/bad-index.wat:1:18
|
1 | (func br_on_null $s)
Expand Down

0 comments on commit eeb5eb9

Please sign in to comment.