Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Self-Reference Substitution #106

Merged
merged 6 commits into from
May 18, 2018
Merged

Conversation

troizky
Copy link
Contributor

@troizky troizky commented May 17, 2018

According to documentation: https://github.com/lightbend/config/blob/master/HOCON.md#examples-of-self-referential-substitutions

A self-reference resolves to the value "below" even if it's part of a path expression. So for example:

foo : { a : { c : 1 } }
foo : ${foo.a}
foo : { a : 2 }

Here, ${foo.a} would refer to { c : 1 } rather than 2 and so the final merge would be { a : 2, c : 1 }.
Recall that for a field to be self-referential, it must have a substitution or value concatenation as its value. If a field has an object or array value, for example, then it is not self-referential even if there is a reference to the field itself inside that object or array.

But I'm getting crash in cases below:

"a": {"b": 27},
"obj": ${a}
# below is failing
"val": ${obj.b}

a = {aa = mama}
b = ${a} { bb = mia }
# below is failing
b.aa = mea
b.bb = culpa

Open Issue #105

Added two tests for nested substitution and assignment.
Fix expected results of tests.
Include definition of class resolve_result
@puppetcla
Copy link

CLA signed by all contributors.

@troizky troizky changed the title fix_nested_subst Fixed Self-Reference Substitution May 18, 2018
@@ -112,34 +112,6 @@ static shared_object subst_env_var_object() {
return resolved;
}

static shared_object subst_nested_chain_object() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove these tests? Decided they duplicated others?

Copy link
Contributor

@MikaelSmith MikaelSmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks sane.

@MikaelSmith MikaelSmith merged commit 9b707e3 into puppetlabs:master May 18, 2018
@MikaelSmith
Copy link
Contributor

Thanks so much for looking into this!

MikaelSmith added a commit to MikaelSmith/cpp-hocon that referenced this pull request May 18, 2018
MikaelSmith added a commit to MikaelSmith/cpp-hocon that referenced this pull request May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants