diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-12-09 13:56:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 13:56:51 +0100 |
commit | 502ac4ed5e539146d31920d50020ae35668f4755 (patch) | |
tree | 1ee912304c3e6d760783d232287f5f9c88f69876 | |
parent | 099285494124dedd7d83a848e213f895f54f9e81 (diff) | |
download | Nim-502ac4ed5e539146d31920d50020ae35668f4755.tar.gz |
fixes a converter handling regression that caused private converters to leak into client modules; fixes #19213; [backport:1.6] (#19229)
-rw-r--r-- | compiler/importer.nim | 6 | ||||
-rw-r--r-- | tests/converter/mdontleak.nim | 3 | ||||
-rw-r--r-- | tests/converter/tdontleak.nim | 10 |
3 files changed, 17 insertions, 2 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index af392f849..acca2c644 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -185,11 +185,13 @@ template addUnnamedIt(c: PContext, fromMod: PSym; filter: untyped) {.dirty.} = for it in mitems c.graph.ifaces[fromMod.position].converters: if filter: loadPackedSym(c.graph, it) - addConverter(c, it) + if sfExported in it.sym.flags: + addConverter(c, it) for it in mitems c.graph.ifaces[fromMod.position].patterns: if filter: loadPackedSym(c.graph, it) - addPattern(c, it) + if sfExported in it.sym.flags: + addPattern(c, it) for it in mitems c.graph.ifaces[fromMod.position].pureEnums: if filter: loadPackedSym(c.graph, it) diff --git a/tests/converter/mdontleak.nim b/tests/converter/mdontleak.nim new file mode 100644 index 000000000..e55c3f87c --- /dev/null +++ b/tests/converter/mdontleak.nim @@ -0,0 +1,3 @@ + +converter toBool(x: uint32): bool = x != 0 +# Note: This convertes is not exported! diff --git a/tests/converter/tdontleak.nim b/tests/converter/tdontleak.nim new file mode 100644 index 000000000..4965fa90a --- /dev/null +++ b/tests/converter/tdontleak.nim @@ -0,0 +1,10 @@ +discard """ + output: '''5''' +joinable: false +""" + +import mdontleak +# bug #19213 + +let a = 5'u32 +echo a |