azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
196 stars 12 forks source link

Crash with is_char_boundary in apply_changes #31

Closed yuriiShmal closed 1 year ago

yuriiShmal commented 1 year ago

This is the output. I don't think I have any fancy unicode characters. If I do, they should be on accident from option + whatever.

Run with RUST_BACKTRACE=full to include source snippets.
Backtrace (most recent call first):
  File "<unknown>", line 0, in core::panicking::panic
  File "<unknown>", line 0, in lang_srv::helpers::apply_changes
  File "<unknown>", line 0, in lang_srv::notification::go
  File "<unknown>", line 0, in lang_srv::run_inner
  File "<unknown>", line 0, in lang_srv::run_stdio
  File "<unknown>", line 0, in millet_ls::main
  File "<unknown>", line 0, in std::sys_common::backtrace::__rust_begin_short_backtrace
  File "<unknown>", line 0, in _main

Millet (0.8.8) crashed. We would appreciate a bug report: https://github.com/azdavis/millet/issues
  assertion failed: self.is_char_boundary(n)
in rust:library/alloc/src/string.rs, line 1811
thread: main
azdavis commented 1 year ago

seems like the bug is here: https://github.com/azdavis/millet/blob/e4ba865aff2184d76a9113a8967120918c6237f0/crates/lang-srv/src/helpers.rs#L54

the underlying bug is probably in PositionDb, which deals with translating utf16 offsets between utf8 ones (essentially). there's a bunch of subtle and tricky string munging code in there. it's heavily derived from rust analyzer's implementation, but i may have made some mistakes when copying it over.

it'd be great if rust analyzer pulled theirs out into a library so i could just copy it wholesale 🤪

azdavis commented 1 year ago

should hopefully be addressed in v0.9.6 since we basically lifted rust-analyzer's handling of this stuff, which is way more thoroughly tested by virtue of rust/rust-analyzer being far more popular than sml/millet