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

Joining an empty list should return an empty list #4853

Merged

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Sep 14, 2020

Fixes #4852.

Note that this changes behavior introduced in TiddlyWiki 5.1.22 by #4396. Specifically, #4396 made join return [""] (a list containing a single empty string) if passed an empty input list, while this PR makes join return [] (an empty list) if passed an empty input list. Before #4396, join would return [null] (a list containing a single null) on empty input, which was causing Red Screen of Death errors. While returning [""] does stop the crashes, I believe that it's not what users would expect, and users would expect join to return an empty list when given empty input.

I would also like code-style comments: I've written if(result.length === 0) return []; as a single line here. Should I instead write this with braces? It seems short enough to merit a one-liner, but some people don't like that.

@Jermolene
Copy link
Member

Thanks @rmunn that makes sense.

I would also like code-style comments: I've written if(result.length === 0) return []; as a single line here. Should I instead write this with braces? It seems short enough to merit a one-liner, but some people don't like that.

Our house style is to always use braces.

@rmunn rmunn force-pushed the bugfix/join-empty-list-should-be-empty branch from 13532e3 to 8b4ca9a Compare September 17, 2020 08:48
@rmunn
Copy link
Contributor Author

rmunn commented Sep 17, 2020

@Jermolene Okay, I've rewritten this PR to use braces instead. And while I was at it, I rebased it onto the current state of the master branch.

@rmunn
Copy link
Contributor Author

rmunn commented Sep 22, 2020

@Jermolene Anything else you want me to change here, or is this ready to merge?

@Jermolene
Copy link
Member

Thanks @rmunn apologies for the delay.

@Jermolene Jermolene merged commit d5cf411 into TiddlyWiki:master Sep 24, 2020
@rmunn rmunn deleted the bugfix/join-empty-list-should-be-empty branch December 4, 2020 10:04
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.

[BUG] Join operator returns non-empty output from empty input
2 participants