compiler/sem: correct macros lineinfo (#10438)
The compiler believes these are where a macro call starts (marked with
`^`):
m "string"
^ ^
This commit addresses that.
This commit is contained in:
parent
6555d89c2c
commit
d72921ecf6
2 changed files with 18 additions and 4 deletions
|
|
@ -450,17 +450,18 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
|
||||||
flags: TExprFlags = {}): PNode =
|
flags: TExprFlags = {}): PNode =
|
||||||
pushInfoContext(c.config, nOrig.info, sym.detailedInfo)
|
pushInfoContext(c.config, nOrig.info, sym.detailedInfo)
|
||||||
|
|
||||||
markUsed(c.config, n.info, sym, c.graph.usageSym)
|
let info = getCallLineInfo(n)
|
||||||
onUse(n.info, sym)
|
markUsed(c.config, info, sym, c.graph.usageSym)
|
||||||
|
onUse(info, sym)
|
||||||
if sym == c.p.owner:
|
if sym == c.p.owner:
|
||||||
globalError(c.config, n.info, "recursive dependency: '$1'" % sym.name.s)
|
globalError(c.config, info, "recursive dependency: '$1'" % sym.name.s)
|
||||||
|
|
||||||
let genericParams = if sfImmediate in sym.flags: 0
|
let genericParams = if sfImmediate in sym.flags: 0
|
||||||
else: sym.ast[genericParamsPos].len
|
else: sym.ast[genericParamsPos].len
|
||||||
let suppliedParams = max(n.safeLen - 1, 0)
|
let suppliedParams = max(n.safeLen - 1, 0)
|
||||||
|
|
||||||
if suppliedParams < genericParams:
|
if suppliedParams < genericParams:
|
||||||
globalError(c.config, n.info, errMissingGenericParamsForTemplate % n.renderTree)
|
globalError(c.config, info, errMissingGenericParamsForTemplate % n.renderTree)
|
||||||
|
|
||||||
#if c.evalContext == nil:
|
#if c.evalContext == nil:
|
||||||
# c.evalContext = c.createEvalContext(emStatic)
|
# c.evalContext = c.createEvalContext(emStatic)
|
||||||
|
|
|
||||||
13
nimsuggest/tests/tmacro_highlight.nim
Normal file
13
nimsuggest/tests/tmacro_highlight.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
macro a(b: string): untyped = discard
|
||||||
|
|
||||||
|
a "string"#[!]#
|
||||||
|
|
||||||
|
discard """
|
||||||
|
$nimsuggest --tester $file
|
||||||
|
>highlight $1
|
||||||
|
highlight;;skMacro;;1;;6;;1
|
||||||
|
highlight;;skType;;1;;11;;6
|
||||||
|
highlight;;skType;;1;;20;;7
|
||||||
|
highlight;;skMacro;;3;;0;;1
|
||||||
|
highlight;;skMacro;;3;;0;;1
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue