diff options
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r-- | compiler/vmgen.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 08d79bbb7..9e1c4d602 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1544,8 +1544,11 @@ proc genTypeLit(c: PCtx; t: PType; dest: var TDest) = n.typ = t genLit(c, n, dest) -proc importcCond(s: PSym): bool {.inline.} = - sfImportc in s.flags and (lfDynamicLib notin s.loc.flags or s.ast == nil) +proc importcCond*(s: PSym): bool {.inline.} = + ## return true to importc `s`, false to execute its body instead (refs #8405) + if sfImportc in s.flags: + if s.kind in routineKinds: + return s.ast.sons[bodyPos].kind == nkEmpty proc importcSym(c: PCtx; info: TLineInfo; s: PSym) = when hasFFI: @@ -1553,7 +1556,8 @@ proc importcSym(c: PCtx; info: TLineInfo; s: PSym) = c.globals.add(importcSymbol(c.config, s)) s.position = c.globals.len else: - localError(c.config, info, "VM is not allowed to 'importc'") + localError(c.config, info, + "VM is not allowed to 'importc' without --experimental:compiletimeFFI") else: localError(c.config, info, "cannot 'importc' variable at compile time; " & s.name.s) |