diff --git a/compiler/linter.nim b/compiler/linter.nim index 77e0a84e4d..1ae1fb0973 100644 --- a/compiler/linter.nim +++ b/compiler/linter.nim @@ -55,7 +55,9 @@ proc beautifyName(s: string, k: TSymKind): string = inc i while i < s.len: if s[i] == '_': - if i > 0 and s[i-1] in {'A'..'Z'}: + if i+1 >= s.len: + discard "trailing underscores should be stripped off" + elif i > 0 and s[i-1] in {'A'..'Z'}: # don't skip '_' as it's essential for e.g. 'GC_disable' result.add('_') inc i