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

Performance issue: top-level field value evaluated twice #1759

Open
bozaro opened this issue Nov 19, 2024 · 1 comment
Open

Performance issue: top-level field value evaluated twice #1759

bozaro opened this issue Nov 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working evaluator

Comments

@bozaro
Copy link
Contributor

bozaro commented Nov 19, 2024

Bug Report

Performance issue: top-level field value evaluated twice.

1. Minimal reproduce step (Required)

kcl run for file:

show = lambda s -> str {
    print("show: ${s}")
    s
}

# `_foo` usage before declaration
foo = _foo

_foo = {
    name: "foo"
    value: show("foo")
}

_bar = {
    name: "bar"
    value: show("bar")
}

# `_bar` usage after declaration
bar = _bar

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

I expect single show: foo and show: bar lines:

show: foo
show: bar
foo:
  name: foo
  value: foo
bar:
  name: bar
  value: bar

3. What did you see instead (Required)

show: foo
show: foo
show: bar
foo:
  name: foo
  value: foo
bar:
  name: bar
  value: bar

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

0.10.9-linux-amd64
@bozaro
Copy link
Contributor Author

bozaro commented Nov 19, 2024

kcl run

_i = {
    _c = 0
}

show = lambda s -> str {
    _c = _i._c
    _i._c = _c + 1
    print("show: ${_c}")
    "${_c}"
}

foo1 = foo
foo2 = foo
foo = {
    name: "foo"
    value: show("foo")
}
foo3 = foo

Output:

show: 0
show: 1
foo1:
  name: foo
  value: '0'
foo2:
  name: foo
  value: '0'
foo:
  name: foo
  value: '1'
foo3:
  name: foo
  value: '0'

@Peefy Peefy added bug Something isn't working evaluator labels Nov 20, 2024
@Peefy Peefy added this to the v0.11.0 Release milestone Nov 20, 2024
@Peefy Peefy self-assigned this Nov 21, 2024
@Peefy Peefy assigned He1pa and unassigned Peefy Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working evaluator
Projects
None yet
Development

No branches or pull requests

3 participants