Skip to content

'undefined' returned instead of undefined in string split with regex #565

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

Closed
malbarbo opened this issue Sep 30, 2024 · 1 comment · Fixed by #566
Closed

'undefined' returned instead of undefined in string split with regex #565

malbarbo opened this issue Sep 30, 2024 · 1 comment · Fixed by #566
Labels
bug Something isn't working

Comments

@malbarbo
Copy link

node and deno evaluates the expression "a ".split(/(d)*/) to [ "a", undefined, " " ], but quickjs-ng evaluates to [ 'a', 'undefined', ' ' ].

@malbarbo malbarbo changed the title 'undefined' return instead of undefined in string split with regex 'undefined' returned instead of undefined in string split with regex Sep 30, 2024
@malbarbo malbarbo changed the title 'undefined' returned instead of undefined in string split with regex 'undefined' returned instead of undefined in string split with regex Sep 30, 2024
@bnoordhuis bnoordhuis added the bug Something isn't working label Sep 30, 2024
@bnoordhuis
Copy link
Contributor

Kind of surprising because e.g. exec() does work correctly - and apparently test262 doesn't test it? Doubly surprising.

Anyway, legit bug - I'll fix it.

bnoordhuis added a commit to bnoordhuis/quickjs that referenced this issue Sep 30, 2024
The expected result of `"ab".split(/(c)*/)[1]` is `undefined` but
was in fact `"undefined"` due to unintentional stringification.

Fixes: quickjs-ng#565
bluesky950520 pushed a commit to bluesky950520/quickjs that referenced this issue Mar 14, 2025
The expected result of `"ab".split(/(c)*/)[1]` is `undefined` but
was in fact `"undefined"` due to unintentional stringification.

Fixes: quickjs-ng/quickjs#565
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants