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

inheritance substitution with array concatenation does not work #608

Open
boekhold opened this issue Jan 6, 2019 · 5 comments
Open

inheritance substitution with array concatenation does not work #608

boekhold opened this issue Jan 6, 2019 · 5 comments

Comments

@boekhold
Copy link

boekhold commented Jan 6, 2019

With the following input:

x-top {
  arr = [
    one
    two
    three
  ]
}

top: ${x-top} {
  arr += "four"
}

When I am parsing this and converting to JSON, the output I am expecting to see is:

{
    "top" : {
        "arr" : [
            "one"
            "two"
            "three"
            "four"
        ]
    },
    "x-top" : {
        "arr" : [
            "one",
            "two",
            "three"
        ]
    }
}

but the actual result I am seeing is:

{
    "top" : {
        "arr" : [
            "four"
        ]
    },
    "x-top" : {
        "arr" : [
            "one",
            "two",
            "three"
        ]
    }
}

If I modify my input to the following, which I view as equivalent (but can't use in my real-world case):

top : {
  arr : [
    one
    two
    three
  ]
} {
  arr += four
}

I am getting the expected result.

@havocp
Copy link
Collaborator

havocp commented Jan 6, 2019

Unfortunately substitutions don’t have lexical scope they are always global references, see #40, #160

The += is sugar for a substitution and expands to arr = ${top.arr} [“four”] I believe.

@havocp
Copy link
Collaborator

havocp commented Jan 6, 2019

Nevermind that may be a confused answer, late at night.

Needs debugging.

@thomschke
Copy link

I run into the same problem when I substitute default values:

default {
}

test = ${default}{
  array += "0"
}

test {
  array += "1"
}

test {
  array += "2"
}

getConfig("test") --> Config(SimpleConfigObject({"array":["2"]})) ???

@thomschke
Copy link

The Problem occurs after the default value substitution:

test {
  array += "0"
}

test {
  array += "1"
}

default {
}

test = ${test}${default}{
}

test = ${test}{
  array += "2"
}

test = ${test}{
  array += "3"
}

getConfig("test) --> Config(SimpleConfigObject({"array":["0","1","3"]}))

@thomschke
Copy link

thomschke commented Feb 25, 2019

test {
  array += "0"
}

test {
  array += "1"
}

default {
}

test = ${default}{
}

test = ${test}{
  array += "2"
}

test = ${test}{
  array += "3"
}

test {
  array += "4"
}

test {
  array += "5"
}

getConfig("test) --> Config(SimpleConfigObject({"array":["5"]}))

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

No branches or pull requests

3 participants