mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 21:17:48 +00:00
fixes #25387 https://stackoverflow.com/questions/30286253/how-to-escape-backslash-in-comment - adding a whitespace or `\t` after `\` breaks the `goto` block - `\* *\` doesn't support nesting, causing problems for using it in the Nim comments
This commit is contained in:
@@ -337,7 +337,10 @@ proc genLineDir(p: BProc, t: PNode) =
|
||||
let line = t.info.safeLineNm
|
||||
|
||||
if optEmbedOrigSrc in p.config.globalOptions:
|
||||
p.s(cpsStmts).add("//" & sourceLine(p.config, t.info) & "\L")
|
||||
var code = sourceLine(p.config, t.info)
|
||||
if code.endsWith('\\'):
|
||||
code.add "#"
|
||||
p.s(cpsStmts).add("// " & code & "\L")
|
||||
let lastFileIndex = p.lastLineInfo.fileIndex
|
||||
let freshLine = freshLineInfo(p, t.info)
|
||||
if freshLine:
|
||||
|
||||
8
tests/ccgbugs/t25387.nim
Normal file
8
tests/ccgbugs/t25387.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
discard """
|
||||
matrix: "--embedsrc=on"
|
||||
"""
|
||||
|
||||
proc trim() =
|
||||
let s = 10
|
||||
let x = s + 5 # user entered literal \
|
||||
trim()
|
||||
Reference in New Issue
Block a user