Description
PublicDoenetMLCore panics with an index-out-of-bounds error when set_source() / return_dast() is called on empty (or whitespace-only) DoenetML source.
Steps to Reproduce
- Initialize a
PublicDoenetMLCore instance
- Call
core.set_flags("{}")
- Call
core.set_source(dast, "") where dast is the parsed result of an empty string
- Call
core.return_dast()
This triggers a Rust panic:
panicked at typed-index-collections-3.3.0/src/slice/slice_index.rs:108:10:
index out of bounds: the len is 0 but the index is 0
Full stack trace includes:
core::panicking::panic_bounds_check
<K as typed_index_collections::slice::slice_index::TiSliceIndex<K,V>>::index
Context
This was discovered while wiring the Rust WASM resolver into the LSP for autocompletion. When a user selects all text in the editor and deletes it, the LSP calls set_source with the empty document, which triggers the panic.
Current Workaround
The RustResolverAdapter in @doenet/lsp-tools now guards against empty source before calling into the Rust core, skipping the sync and falling back to JS-only autocompletion.
Description
PublicDoenetMLCorepanics with an index-out-of-bounds error whenset_source()/return_dast()is called on empty (or whitespace-only) DoenetML source.Steps to Reproduce
PublicDoenetMLCoreinstancecore.set_flags("{}")core.set_source(dast, "")wheredastis the parsed result of an empty stringcore.return_dast()This triggers a Rust panic:
Full stack trace includes:
Context
This was discovered while wiring the Rust WASM resolver into the LSP for autocompletion. When a user selects all text in the editor and deletes it, the LSP calls
set_sourcewith the empty document, which triggers the panic.Current Workaround
The
RustResolverAdapterin@doenet/lsp-toolsnow guards against empty source before calling into the Rust core, skipping the sync and falling back to JS-only autocompletion.