Skip to content

Commit ea6409c

Browse files
Pikeflodolo
authored andcommitted
bug 1447905, missing dependencies in REPLACE (#56)
The replacements in a REPLACE transform are in a dict, which fold() didn't go in to.
1 parent 9030138 commit ea6409c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

fluent/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def fold_(vals, acc):
3636
acc = fold(fun, head, acc)
3737
if isinstance(head, list):
3838
acc = fold_(head, acc)
39+
if isinstance(head, dict):
40+
acc = fold_(head.values(), acc)
3941

4042
return fold_(tail, fun(acc, head))
4143

tests/migrate/test_util.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import fluent.syntax.ast as FTL
77
from fluent.util import fold
8-
from fluent.migrate.transforms import CONCAT, COPY, Source
8+
from fluent.migrate.transforms import CONCAT, COPY, REPLACE, Source
99

1010

1111
def get_source(acc, cur):
@@ -81,3 +81,20 @@ def test_copy_concat(self):
8181
fold(get_source, node, ()),
8282
(('path1', 'key1'), ('path2', 'key2'))
8383
)
84+
85+
def test_copy_in_replace(self):
86+
node = FTL.Message(
87+
FTL.Identifier('hello'),
88+
value=REPLACE(
89+
'path1',
90+
'key1',
91+
{
92+
"foo": COPY('path2', 'key2')
93+
}
94+
)
95+
)
96+
97+
self.assertEqual(
98+
fold(get_source, node, ()),
99+
(('path2', 'key2'), ('path1', 'key1'))
100+
)

0 commit comments

Comments
 (0)