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

[Bug] Using ${foo.bar} returns ${foo} if foo is not a container #364

Closed
odelalleau opened this issue Sep 9, 2020 · 2 comments · Fixed by #366
Closed

[Bug] Using ${foo.bar} returns ${foo} if foo is not a container #364

odelalleau opened this issue Sep 9, 2020 · 2 comments · Fixed by #366
Labels
bug Something isn't working

Comments

@odelalleau
Copy link
Collaborator

cfg = OmegaConf.create(dict(foo=0, bug="${foo.bar}"))
print(cfg.bug)

The above code prints "0" while I would expect it to crash.

What puzzles me is that this behavior is actually tested right now:

def test_indirect_interpolation2() -> None:
    d = {
        "a": {"aa": 10},
        "b": "${a.aa}",
        "c": "${b.aa}",
    }

    cfg = OmegaConf.create(d)
    assert cfg.c == 10

This test doesn't make sense to me: accessing cfg.c should crash since b is equal to 10 so b.aa should be invalid. Am I missing something?

@omry
Copy link
Owner

omry commented Sep 9, 2020

This looks like a bug in the test and in the code.
This makes more sense:

def test_indirect_interpolation2() -> None:
    d = {
        "a": {"aa": 10},
        "b": "${a.aa}",
        "c": "${b}",
    }

@omry omry added this to the OmegaConf 2.0.1 milestone Sep 9, 2020
@omry omry added the bug Something isn't working label Sep 9, 2020
@omry
Copy link
Owner

omry commented Sep 9, 2020

feel free to send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants