Skip to content

Commit

Permalink
fix break labels, but don't reformat the whole tests file
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Feb 23, 2022
1 parent 8c92a8f commit c1ce48e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions boa_engine/src/bytecompiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,11 +1480,12 @@ impl<'b> ByteCompiler<'b> {
break;
}
}
assert!(
found,
"Undefined label '{}'",
self.interner().resolve_expect(label_name)
);
if !found {
return self.context.throw_syntax_error(format!(
"Undefined label '{}'",
self.interner().resolve_expect(label_name)
));
}
} else {
self.jump_info
.last_mut()
Expand Down
3 changes: 1 addition & 2 deletions boa_engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,14 @@ fn for_loop_iteration_variable_does_not_leak() {
}

#[test]
#[should_panic]
fn test_invalid_break_target() {
let src = r#"
while (false) {
break nonexistent;
}
"#;

let _ = &exec(src);
assert!(matches!(Context::default().eval(src.as_bytes()), Err(_)));
}

#[test]
Expand Down

0 comments on commit c1ce48e

Please sign in to comment.