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

|= still holds on to a reference on the value to be modified #2706

Open
nicowilliams opened this issue Jul 12, 2023 · 0 comments
Open

|= still holds on to a reference on the value to be modified #2706

nicowilliams opened this issue Jul 12, 2023 · 0 comments

Comments

@nicowilliams
Copy link
Contributor

nicowilliams commented Jul 12, 2023

def _modify(paths; update):
    reduce path(paths) as $p ([., []];
        . as $dot
      | null
      | label $out
      | ($dot[0] | getpath($p)) as $v
      | (
          (   $$$$v   # <----- here we let go of $v, but $dot[0] at $p still has the same value
            | update
            | (., break $out) as $v
            | $$$$dot
            | setpath([0] + $p; $v)
          ),
          (
              $$$$dot
            | setpath([1, (.[1] | length)]; $p)
          )
        )
    ) | . as $dot | $dot[0] | delpaths($dot[1]);

We should setpath([0] + $p; null) before the $$$$v | update.

EDIT: This is by code inspection. I haven't tested this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants