Skip to content

Conversation

UnderscoreTud
Copy link
Member

Problem

There are a few issues that this PR aims to address. Most notably, there is currently no straightforward way to pass entire list structures around. The other issues consist of a couple of minor bugs introduced by the previous PR.

  • Setting the default value of a function parameter to a list throws an error when the function is ran. This is caused by the function not properly ensuring (More info here Returning list of default values of function throws severe error #8220).
  • Providing a function parameter with a list of separate keyed expressions containing the same keys (for example, foo(keyed {_list1::*}, keyed {_list2::*}) where list1 and list2 both contain values corresponding to the same key) would throw an exception.

Solution

This PR introduces new method to get an expression's values recursively, along with a corresponding recursive expression that makes use of that behavior. When combined with the keyed expression, it allows both keys and values to be returned recursively, allowing entire structures to passed around seamlessly between different contexts.

Addressing the aforementioned issues:

  • The first issue is resolved by adding a centralized method to the Parameter class that evaluates expressions with respect to the parameter's modifiers. This unfortunately makes Fix function parameters with default value as list causing error #8221 obsolete.
  • The second issue is resolved by ensuring that any duplicate keys are discarded. If a key appears multiple times, only the first value is kept.

Testing Completed

StructFunction.sk, ExprRecursive.sk

Supporting Information

Below is a complete example showing how various combinations behave:

set {_first::a::b} to "value1"
set {_first::c} to "value2"

set {_second::*} to {_first::*}
# {_second::1} = "value2"

set {_second::*} to keyed {_first::*}
# {_second::c} = "value2"

set {_second::*} to recursive {_first::*}
# {_second::1} = "value1"
# {_second::2} = "value2"

set {_second::*} to keyed recursive {_first::*}
# {_second::a::b} = "value1"
# {_second::c} = "value2"

Using functions:

function shallow_list(list: objects) returns objects:
    return {_list::*}

function deep_list(list: objects) returns objects:
    return recursive {_list::*}

# ...

set {_first::a::b} to "value1"
set {_first::c} to "value2"

set {_second::*} to shallow_list({_first::*})
# {_second::1} = "value2"

set {_second::*} to keyed shallow_list({_first::*})
# {_second::1} = "value2"

set {_second::*} to shallow_list(keyed {_first::*})
# {_second::1} = "value2"

set {_second::*} to keyed shallow_list(keyed {_first::*})
# {_second::c} = "value2"

# =============

set {_second::*} to deep_list({_first::*})
# {_second::1} = "value2"

set {_second::*} to keyed deep_list({_first::*})
# {_second::1} = "value2"

set {_second::*} to deep_list(keyed {_first::*}) # passing in a keyed list will automatically
                                                                      #   pass it as a keyed recursive list
# {_second::1} = "value1"
# {_second::2} = "value2"

set {_second::*} to keyed deep_list(keyed {_first::*})
# {_second::a::b} = "value1"
# {_second::c} = "value2"

Completes: #8220
Related: none

@UnderscoreTud UnderscoreTud requested review from a team and Efnilite as code owners October 17, 2025 17:34
@UnderscoreTud UnderscoreTud requested review from APickledWalrus and erenkarakal and removed request for a team October 17, 2025 17:34
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Oct 17, 2025
@UnderscoreTud UnderscoreTud added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. and removed needs reviews A PR that needs additional reviews labels Oct 17, 2025
@UnderscoreTud UnderscoreTud changed the base branch from master to dev/feature October 17, 2025 17:37
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Oct 17, 2025
@sovdeeth sovdeeth moved this to In Review in 2.14 Releases Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

1 participant