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

function/stdlib: ValuesFunc precise handling of marks #95

Merged
merged 1 commit into from
Apr 19, 2021

Conversation

apparentlymart
Copy link
Collaborator

Previously ValuesFunc was just using the safe default behavior where if any argument contains any marked values at all then the result is automatically given the same marks.

That's valid but overly conservative, because it means that an unmarked map with a single marked element value will become a wholly-marked list result, rather than an unmarked list with one marked element value.

Now we'll opt in to custom mark handling within the function itself, and handle shallowly the marking of the overall collection -- propagating it to the result -- while letting the values inside retain their individual markings as needed.

We were previously lacking unit tests for the values function, I think because it's a pretty old one from when cty was new, so this also includes additional test cases that are not directly related to marked values but cover the other interesting cases that this function must deal with, either directly (with its own code) or indirectly (by calling cty operation functions that handle it automatically).

Previously ValuesFunc was just using the safe default behavior where if
any argument contains any marked values at all then the result is
automatically given the same marks.

That's overly conservative though, because it means that an unmarked
map with a single marked element value will become a wholly-marked list
result, rather than an unmarked list with one marked element value.

Now we'll opt in to custom mark handling within the function itself, and
handle shallowly the marking of the overall collection -- propagating it
to the result -- while letting the values inside retain their individual
markings as needed.

We were previously lacking unit tests for the values function, I think
because it's a pretty old one from when cty was new, so this also includes
additional test cases that are not directly related to marked values but
cover the other interesting cases that this function must deal with,
either directly (with its own code) or indirectly (by calling cty
operation functions that handle it automatically).
@apparentlymart apparentlymart merged commit 9a2d67f into main Apr 19, 2021
@apparentlymart apparentlymart deleted the f-func-values-sensitive branch April 19, 2021 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant