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

Fixed #1314: yielding a function should not call the function #1315

Merged
merged 2 commits into from
Jan 27, 2017

Conversation

giltayar
Copy link
Contributor

@giltayar giltayar commented Jan 4, 2017

When rejecting a non-promise value, string.replace is used, and the value is passed as second parameter. But string.replace, if the second parameter is a function, will call that function.
This commit fixes this by using value.toString().

…tion

   When rejecting a non-promise value, string.replace is used,
    and the value is passed as second parameter.
    But string.replace, if the second value is a function, will
    call that function.
    This commit fixes this by using value.toString().
@@ -160,7 +160,8 @@ PromiseSpawn.prototype._continue = function (result) {
if (maybePromise === null) {
this._promiseRejected(
new TypeError(
YIELDED_NON_PROMISE_ERROR.replace("%s", value) +
YIELDED_NON_PROMISE_ERROR.replace("%s",
value == null ? value : value.toString()) +
Copy link
Owner

@petkaantonov petkaantonov Jan 4, 2017

Choose a reason for hiding this comment

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

value + "" is sufficient

@benjamingr
Copy link
Collaborator

LGTM, @petkaantonov ?

@giltayar
Copy link
Contributor Author

giltayar commented Jan 6, 2017

Funny what I just saw in /r/javascript: https://www.reddit.com/r/javascript/comments/5m2e8j/string_vs_tostring/dc0wzr5/

@benjamingr benjamingr merged commit 0566325 into petkaantonov:master Jan 27, 2017
@benjamingr
Copy link
Collaborator

Thanks!

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.

3 participants