dprint / dprint-plugin-json

JSON code formatting plugin for dprint.
https://dprint.dev/plugins/json
MIT License
18 stars 5 forks source link

Panic on invalid JSON #13

Closed lucacasonato closed 1 year ago

lucacasonato commented 1 year ago

Describe the bug

dprint-plugin-json version: 0.17.1

Input Code

{},

Note the two newlines after the comma.

Expected Output

some diagnostic about this being invalid code

Actual Output

Panic!

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.32.1
Args: ["deno", "fmt", "test.json"]

thread 'tokio-runtime-worker' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:518:5
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: alloc::raw_vec::capacity_overflow
   3: alloc::str::<impl str>::repeat
   4: dprint_core::formatting::utils::string_utils::format_diagnostic
   5: dprint_plugin_json::format_text::format_text
   6: deno::tools::fmt::format_json
   7: deno::tools::fmt::format_file
   8: tokio::runtime::task::raw::poll