Skip to content

Commit 0adfb09

Browse files
tiyeCopilot
andauthored
copilot try
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 989dcb7 commit 0adfb09

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/s_expr.mbt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ fn format_lispy_expr(self : Cirru, indent : Int) -> String raise FormatError {
5353
} else {
5454
let s0 = token[0]
5555
if s0 == '|' || s0 == '"' {
56-
let sliced = (try? token[1:]).unwrap().to_string()
56+
if token.length() < 2 {
57+
raise FormatError("token too short to slice: \{token}")
58+
}
59+
let sliced = (try? token[1:]).unwrap_or_else(|| raise FormatError("failed to slice token: \{token}")).to_string()
5760
"\"" + escape_string(sliced) + "\""
5861
} else if token.contains(" ") ||
5962
token.contains("\n") ||

0 commit comments

Comments
 (0)