summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/layouter.nim14
-rw-r--r--nimpretty/tests/expected/simple.nim11
-rw-r--r--nimpretty/tests/simple.nim11
3 files changed, 31 insertions, 5 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim
index ec9db6aad..36c4e07a3 100644
--- a/compiler/layouter.nim
+++ b/compiler/layouter.nim
@@ -551,11 +551,15 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) =
     if not preventComment:
       emitComment(em, tok, dontIndent = false)
   of tkIntLit..tkStrLit, tkRStrLit, tkTripleStrLit, tkGStrLit, tkGTripleStrLit, tkCharLit:
-    let lit = fileSection(em.config, em.fid, tok.offsetA, tok.offsetB)
-    if endsInAlpha(em) and tok.tokType notin {tkGStrLit, tkGTripleStrLit}: wrSpace(em)
-    em.lineSpan = countNewlines(lit)
-    if em.lineSpan > 0: calcCol(em, lit)
-    wr em, lit, ltLit
+    if not em.inquote:
+      let lit = fileSection(em.config, em.fid, tok.offsetA, tok.offsetB)
+      if endsInAlpha(em) and tok.tokType notin {tkGStrLit, tkGTripleStrLit}: wrSpace(em)
+      em.lineSpan = countNewlines(lit)
+      if em.lineSpan > 0: calcCol(em, lit)
+      wr em, lit, ltLit
+    else:
+      if endsInAlpha(em): wrSpace(em)
+      wr em, tok.literal, ltLit
   of tkEof: discard
   else:
     let lit = if tok.ident != nil: tok.ident.s else: tok.literal
diff --git a/nimpretty/tests/expected/simple.nim b/nimpretty/tests/expected/simple.nim
index d13558621..e711eb3b6 100644
--- a/nimpretty/tests/expected/simple.nim
+++ b/nimpretty/tests/expected/simple.nim
@@ -16,3 +16,14 @@ proc a() =
 discard ## comment 3
 
 discard # comment 4
+
+
+# bug #20553
+
+let `'hello` = 12
+echo `'hello`
+
+
+proc `'u4`(n: string) =
+  # The leading ' is required.
+  discard
diff --git a/nimpretty/tests/simple.nim b/nimpretty/tests/simple.nim
index 435bd6bd2..2a01a176e 100644
--- a/nimpretty/tests/simple.nim
+++ b/nimpretty/tests/simple.nim
@@ -16,3 +16,14 @@ proc a() =
 discard## comment 3
 
 discard # comment 4
+
+
+# bug #20553
+
+let `'hello` = 12
+echo `'hello`
+
+
+proc `'u4`(n: string) =
+  # The leading ' is required.
+  discard