From cf5048205fae1bec8141c4df809164240ec12f25 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Mon, 20 Dec 2021 06:25:02 +1100 Subject: [PATCH] Allow empty span slice for now (#529) --- crates/nu-protocol/src/span.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/span.rs b/crates/nu-protocol/src/span.rs index 4196e751b3..1a5cf900f5 100644 --- a/crates/nu-protocol/src/span.rs +++ b/crates/nu-protocol/src/span.rs @@ -48,11 +48,13 @@ impl Span { } } +/// Used when you have a slice of spans of at least size 1 pub fn span(spans: &[Span]) -> Span { let length = spans.len(); if length == 0 { - panic!("Internal error: tried to create a 0-length span") + // TODO: do this for now, but we might also want to protect against this case + Span { start: 0, end: 0 } } else if length == 1 { spans[0] } else {