fixes, test

This commit is contained in:
metagn
2024-11-03 11:00:21 +03:00
parent 2cde18ca7d
commit 44026f49bd
4 changed files with 16 additions and 4 deletions

View File

@@ -1902,7 +1902,7 @@ proc skipGenericOwner*(s: PSym): PSym =
proc originatingModule*(s: PSym): PSym =
result = s
while result.kind != skModule: result = result.owner
while result != nil and result.kind != skModule: result = result.owner
proc isRoutine*(s: PSym): bool {.inline.} =
result = s.kind in skProcKinds

View File

@@ -2622,8 +2622,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
proc determineType(c: PContext, s: PSym) =
if s.typ != nil: return
#if s.magic != mNone: return
if s.ast.isNil and sfForward notin s.flags:
globalError(c.config, s.info, errIllFormedAstX, "symbol of kind " & $s.kind)
if s.ast.isNil and sfForward notin s.flags:
globalError(c.config, s.info, errIllFormedAstX, "symbol of kind " & $s.kind & " has no implementation")
discard semProcAux(c, s.ast, s.kind, {})
proc semIterator(c: PContext, n: PNode): PNode =

View File

@@ -2184,7 +2184,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
else: regs[rc].node.strVal
if k < 0 or k > ord(high(TSymKind)):
internalError(c.config, c.debug[pc], "request to create symbol of invalid kind")
var sym = newSym(k.TSymKind, getIdent(c.cache, name), c.idgen, c.module, c.debug[pc])
var sym = newSym(k.TSymKind, getIdent(c.cache, name), c.idgen, c.module.owner, c.debug[pc])
incl(sym.flags, sfGenSym)
regs[ra].node = newSymNode(sym)
regs[ra].node.flags.incl nfIsRef

View File

@@ -0,0 +1,12 @@
# issue #15097
import macros
macro foo: untyped =
result = newStmtList()
let tmp = genSym(nskProc, "tmp") #[tt.Error
^ illformed AST: symbol of kind skProc has no implementation]#
result.add quote do:
let bar = `tmp`()
foo()