From 6778a5e5c80936478118f09f657293b4927cc198 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Thu, 11 Jan 2024 18:49:27 +0100 Subject: [PATCH] source: fix crash when len(source) is zero! --- compiler/source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/source.py b/compiler/source.py index 4b85a5f..8a90bc2 100644 --- a/compiler/source.py +++ b/compiler/source.py @@ -126,7 +126,7 @@ class SourceLocation: def show_in_source(self) -> str: source = self.source.splitlines(keepends=False) - line_number_maxlen = int(math.log10(len(source)) + 1) + line_number_maxlen = 1 if not len(source) else int(math.log10(len(source)) + 1) lines = source[self.begin.line:self.end.line + 1] result = [] begin_char = self.begin.character