Skip to content

If nesting causes unpredictable results #1837

Open
@spastorclovr

Description

@spastorclovr

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)


options = {}

if "a" == "a":
    _extra_resource = options?.extraResources

    if _extra_resource:
        _env_from_extra =[{"hello":"bonjour"}]

    _deploy_manifest = {
        env = _env_from_extra
    }

    if "s" != "s":
        _items = ["a"]
        print("RETURNING IN IF ${_items}")
    else:
        _items = ["b"]
        print("RETURNING IN ELSE ${_items}")
    print("RETURNING in main ${_items}")

2. What did you expect to see? (Required)

RETURNING IN ELSE [b]
RETURNING in main [b]

3. What did you see instead (Required)

RETURNING in main Undefined
RETURNING in main Undefined
RETURNING in main Undefined
RETURNING IN ELSE Undefined
RETURNING in main Undefined

BUT if you comment

env = _env_from_extra
The expected result is displayed..

And finally if you remove the top if "if "a" == "a":" everything works smoothly.
This is a blocker for us as it brings uncertainty on how well our kcl functions (crossplane) could run depending on some level of IF confitions.

4. What is your KCL components version? (Required)

0.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions