fix(arrayfunc): fix the behavior of assoc=([key]+=value) - #5
Open
akinomyoga wants to merge 1 commit into
Open
akinomyoga wants to merge 1 commit into
akinomyoga wants to merge 1 commit into
Conversation
akinomyoga
force-pushed
the
assoc_append
branch
6 times, most recently
from
September 8, 2026 07:53
c07bdba to
91f5a3f
Compare
This patch first stores the generated key-value pairs into an
independent hash table NHASH without modifying the old contents of the
associative array, even for the form `assoc+=(...)'. Then, it merges
the generated key-value pairs into the associative-array variable
finally.
* The new function `make_assoc_var_kvpair ()' (arrayfunc.c) was made
based on `make_array_variable_value ()' (arrayfunc.c:177), but it
stores the constructed key-value pair in the argument NHASH instead
of returning the constructed value as the return value. Also, when
retrieving the existing value for `[key]+=rhs', it attempts to check
NHASH first and then fall back to the old contents of the
associative array.
* The new function `bind_assoc_kvpairs ()' (arrayfunc.c) was made
based on `bind_assoc_var_internal ()' (arrayfunc.c:225). It merges
the key-value pairs stored in NHASH into the associative array that
VAR points to, or replaces it with NHASH. The two XXX comments were
inherited from `bind_assoc_var_internal ()'.
* To implement this, I have added a utility function `hash_walk_arg
()' (hashlib.{h,c}), extending the existing `hash_walk ()'
(hashlib.c:397). I have also added `assoc_merge ()' (assoc.{h,c})
Although it is not included in this patch, `build_hashcmd ()',
`build_aliasvar ()', and `flatten ()' in variables.c may also be
rewritten using `hash_walk_arg ()', instead of directly touching the
internal structures of the hash table.
akinomyoga
force-pushed
the
assoc_append
branch
from
September 19, 2026 13:54
91f5a3f to
f4fcb88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.