dprint / dprint-plugin-json

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

no meaningful error message given for `\u200b` in text #6

Closed trim21 closed 2 years ago

trim21 commented 2 years ago

Describe the bug

dprint-plugin-json version: 0.13.2

Input Code

{
  "compilerOptions": {
    "esModuleInterop": true​
  }
}

Expected Output

something meaningful.

Actual Output

Error formatting C:/Users/Trim21/proj/cactbot/tsconfig-for-webpack.json. Message: RuntimeError: unreachable
    at __rust_start_panic (<module>[543]:0x3a39e)
    at rust_panic (<module>[540]:0x3a364)
    at std::panicking::rust_panic_with_hook::ha223473efd20893e (<module>[535]:0x3a0ac)
    at std::panicking::begin_panic_handler::{{closure}}::h0eb6605d81329fe7 (<module>[527]:0x39a44)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h8c7d312a147e1df9 (<module>[526]:0x39993)
    at rust_begin_unwind (<module>[534]:0x39f85)
    at core::panicking::panic_fmt::hca0bee0b11468063 (<module>[619]:0x40554)
    at core::str::slice_error_fail::h2e3fd31345cd0cd6 (<module>[639]:0x41a85)
    at dprint_core::formatting::utils::string_utils::format_diagnostic::ha38e663e29e48684 (<module>[452]:0x351da)
    at dprint_plugin_json::format_text::format_text::h90fe515ff2009a58 (<module>[240]:0x1aacb)
    at format (<module>[208]:0x177de)
Had 1 error(s) formatting.

https://dprint.dev/playground/#code/N4WAUABBBEDGD2BbADgSwDYFMBOB5ZALqvAHYDO0AXBKJFDJmQLLwAmArlgJIkE7zIqEAtnaZA0ATgoAX3CywQA/language/json

dsherret commented 2 years ago

That's weird it failed. Also, did you meant to close this?

dsherret commented 2 years ago

Oh, looks like an extra character at the end of the line?

Would be nice if this errored similar to prettier and displayed this in the playground:

https://prettier.io/playground/#N4Igxg9gdgLgprEAuEwA6UAEm3ggWwAcBLAGzgCcB5QmY6AZ1yU3S2xxDgYFkIATAK7kAkrEoRCzTDAqC4gaAIM2AL4Y1UEABoQkuo2SgAhhQoQA7gAUTCBshBHS5owE87OgEYUjYANZwYAGUjfDgAGWIoOGQAM0cGOE9vPwDAwh9IgHNkWXkdOHwPOH5+YrCjKEzBI0y4ADEICnwjGDpK+yNBGAhtEAALGHxSAHU+4ngGdLA4QNtx4gA3cZd7MAZ3EEiEihhLb0zm2PjEkAArBgAPQKzyAEVBCHgj0gSddIpt+3PoXsIKSJgw2I-BgfWQAA4AAxvMwJYbeQj2P7cSgLaI6ACOD3ge0kdhQRgYAFoosVir0KHAscRKXsaockHEXicEvhiDk5CybnB7o9oozjjoYEYPECQWCkAAmIXeMhZADCBAZXAYAFZeoIEgAVEX4pmvEALeRiUqwQJgf60ACCUH4gRgLnIzwSKhUQA

trim21 commented 2 years ago

I find there is an \u200b after e, this json file is not valid so it's not strange that dprint can't handle it. Therefore I close it.

trim21 commented 2 years ago

If you think it a meaningful issue, I'm happy you re-open it.

dsherret commented 2 years ago

It is. It should say it can't understand this character. I think it's a bug in the json parser.