fixes #15848 [backport:1.2] (#17959)

This commit is contained in:
Andreas Rumpf 2021-05-07 16:50:11 +02:00 • committed by GitHub
commit 51f3ef6cb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,23 @@
discard """
cmd: "nim c --styleCheck:error --styleCheck:usages $file"
errormsg: "'BAD_STYLE' should be: 'BADSTYLE'"
line: 20
"""
import strutils
proc BADSTYLE(c: char) = discard
proc toSnakeCase(s: string): string =
result = newStringOfCap(s.len + 3)
for i in 0..<s.len:
if s[i] in {'A'..'Z'}:
if i > 0 and s[i-1] in {'a'..'z'}:
result.add '_'
result.add toLowerAscii(s[i])
else:
result.add s[i]
BAD_STYLE(s[i])
echo toSnakeCase("fooBarBaz Yes")