Skip to content

nested if statement does not mutate variable as expected in KCLΒ #1978

@kamilkrampa

Description

@kamilkrampa

Bug Report

When using a nested if block to assign a value to a variable in KCL, the assignment does not appear to take effect.

Also, print statements inside the if block are triggered multiple times

1. Minimal reproduce step (Required)

_engine_version = None
_engine_name = None

if _engine_version == None:
    print("entered engine version == None")
    if _engine_name == "redis":
        print("entered nested if _engine_name == redis")
        _engine_version = "7.1"
    else:
        print("entered nested else")
        _engine_version = "test"

items = {
    "engineVersion": _engine_version
}

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

entered engine version == None
entered nested else
items:
  engineVersion: test

3. What did you see instead (Required)

entered engine version == None
entered engine version == None
entered engine version == None
entered nested else
items:
  engineVersion: null

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

kcl version 0.11.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions