Skip to content

Commit

Permalink
Fix vdbg! depth and JSON error messages (#5138)
Browse files Browse the repository at this point in the history
### Description

Two small fixes:

- The `vdbg!(vc; depth = 1)` macro would error out
  - the expanded `__init` syntax wasn't updated in #4995
- The JSON error message could panic if the line and/or column was `0`
- This comes up when trying to deserialize into a struct with a missing
prop, because it errors at the opening `{` brace

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
jridgewell committed May 31, 2023
1 parent 5c69348 commit 945756e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/turbo-tasks-fs/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ impl UnparseableJson {
Self {
message: inner.to_string().into(),
path: Some(e.path().to_string()),
start_location: Some((inner.line() - 1, inner.column() - 1)),
start_location: Some((
inner.line().saturating_sub(1),
inner.column().saturating_sub(1),
)),
end_location: None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks/src/debug/vdbg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ macro_rules! vdbg {
(__repeat $str:literal) => { "" };

($($val:expr),* ; depth = $depth:expr) => {
$crate::vdbg!(__init $depth ; $($val),*)
$crate::vdbg!(__init $depth ; [ $($val),* ] [])
};
($($val:expr),+ $(,)?) => {
$crate::vdbg!(__init usize::MAX ; [ $($val),* ] [])
Expand Down

0 comments on commit 945756e

Please sign in to comment.