Skip to content

Commit 7cf5e73

Browse files
Araqnarimiran
authored andcommitted
fixes a converter handling regression that caused private converters to leak into client modules; fixes #19213; [backport:1.6] (#19229)
(cherry picked from commit 502ac4e)
1 parent c14008d commit 7cf5e73

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

compiler/importer.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ template addUnnamedIt(c: PContext, fromMod: PSym; filter: untyped) {.dirty.} =
185185
for it in mitems c.graph.ifaces[fromMod.position].converters:
186186
if filter:
187187
loadPackedSym(c.graph, it)
188-
addConverter(c, it)
188+
if sfExported in it.sym.flags:
189+
addConverter(c, it)
189190
for it in mitems c.graph.ifaces[fromMod.position].patterns:
190191
if filter:
191192
loadPackedSym(c.graph, it)
192-
addPattern(c, it)
193+
if sfExported in it.sym.flags:
194+
addPattern(c, it)
193195
for it in mitems c.graph.ifaces[fromMod.position].pureEnums:
194196
if filter:
195197
loadPackedSym(c.graph, it)

tests/converter/mdontleak.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
converter toBool(x: uint32): bool = x != 0
3+
# Note: This convertes is not exported!

tests/converter/tdontleak.nim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
discard """
2+
output: '''5'''
3+
joinable: false
4+
"""
5+
6+
import mdontleak
7+
# bug #19213
8+
9+
let a = 5'u32
10+
echo a

0 commit comments

Comments
 (0)