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

Fix empty expanded value for duplicate key #260

Merged
merged 1 commit into from Jul 16, 2020

Conversation

bbc2
Copy link
Collaborator

@bbc2 bbc2 commented Jul 3, 2020

Example problematic file:

hello=hi
greetings=${hello}
goodbye=bye
greetings=${goodbye}

It would result in greetings being associated with the empty string
instead of "bye".

The problem came from the fact that bindings were converted to a dict,
and so deduplicated by key, before being interpolated. The dict would
be {"hello": "hi", "greetings": "${goodbye}", "goodbye": "bye"} in the
earlier example, which shows why interpolation wouldn't work: goodbye
would not be defined when greetings was interpolated.

This commit fixes that by passing all values in order, even if there are
duplicated keys.

Closes #197

Example problematic file:

```bash
hello=hi
greetings=${hello}
goodbye=bye
greetings=${goodbye}
```

It would result in `greetings` being associated with the empty string
instead of `"bye"`.

The problem came from the fact that bindings were converted to a dict,
and so deduplicated by key, before being interpolated.  The dict would
be `{"hello": "hi", "greetings": "${goodbye}", "goodbye": "bye"}` in the
earlier example, which shows why interpolation wouldn't work: `goodbye`
would not be defined when `greetings` was interpolated.

This commit fixes that by passing all values in order, even if there are
duplicated keys.
@coveralls
Copy link

coveralls commented Jul 3, 2020

Coverage Status

Coverage increased (+0.05%) to 89.855% when pulling 8ffd21c on bbc2:fix-empty-expanded-value-duplicate-key into e4bbb8a on theskumar:master.

@bbc2 bbc2 force-pushed the fix-empty-expanded-value-duplicate-key branch from 1e99042 to 8ffd21c Compare July 3, 2020 17:00
@bbc2 bbc2 merged commit 4b43436 into theskumar:master Jul 16, 2020
@bbc2 bbc2 deleted the fix-empty-expanded-value-duplicate-key branch July 16, 2020 19:45
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.

Unexpected Behavior when Parsing Duplicate Key
2 participants