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

fix: list_transpose() takes into account all elements for the template #1136

Merged
merged 6 commits into from
Aug 15, 2024

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Aug 15, 2024

This introduces an error for the case when mixing named and unnamed elements, it was a silent error before.

Closes #1128.

Code
list_transpose(list(x = list(a = 1, b = 2), y = list(3, 4)))
Condition
Error in `fn()`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth making this error a bit more clear? At a minimum, it seems like it'd be worth wrapping it to give some context and a more useful call.

@krlmlr
Copy link
Member Author

krlmlr commented Aug 15, 2024

Good catch, done. No idea how I missed committing the snapshots...

@krlmlr
Copy link
Member Author

krlmlr commented Aug 15, 2024

Do you still think it's worth having a try_catch() around this?

@hadley
Copy link
Member

hadley commented Aug 15, 2024

I think so? It's hard to tell that this message arises because by generating a default value for an argument.

vec_set_union,
error_call = caller_env()
indexes <- map(x, vec_index)
try_fetch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withCallingHandlers should be adequate here.

vctrs_error_ptype2 = function(e) {
cli::cli_abort(
"Can't combine named and unnamed vectors.",
arg = template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs call still?

@hadley
Copy link
Member

hadley commented Aug 15, 2024

Closes #1128.

@hadley hadley closed this Aug 15, 2024
@hadley hadley reopened this Aug 15, 2024
@hadley hadley merged commit 770bbfe into tidyverse:main Aug 15, 2024
13 checks passed
@krlmlr krlmlr deleted the b-1128-list-transpose branch August 15, 2024 23:31
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.

Possible bug with list_transpose
2 participants