WIP: #281: Fixes for lists expansion operator (`+=`)
Root Casuse
Actually, the += operator took the HOCON definition too literally.
When the x += y was met, it created a substitution for x.
Then, when the entire config is read, that substitution is applied at the exact name x.
However, if x was inside a dict object, the x would not be resolved.
Changes
- Added tests covering broken operator behavior
- The
+=operator now creates a smarter substitution
ToDo:
- [ ] Check other conditions when it may fail
- [ ] (?) Resolve
+=in-place?
Coverage decreased (-1.9%) to 94.294% when pulling aa133cf9ca212dcea3f582f85f817448e692a70b on USSX-Hares:bug/281-expand-list-fixes into be660deb6d6a5a175d384792e208fd39986758ea on chimpler:master.
I've found that pyhocon's implementation of the operator += diverges from the HOCON standard: in HOCON, += (1) can only be applied to arrays and (2) can only append elements to arrays, not extend arrays with the arrays.
According to https://hocon-playground.herokuapp.com/, the following configuration:
d {
x = [1,2]
x += [3,4]
}
resolves into the following:
d {
x=[
1,
2,
[
3,
4
]
]
}
@darthbear, what do you think?