src: replace FromJust() with Check() when possible#27162
Closed
sam-github wants to merge 3 commits intonodejs:masterfrom
Closed
src: replace FromJust() with Check() when possible#27162sam-github wants to merge 3 commits intonodejs:masterfrom
sam-github wants to merge 3 commits intonodejs:masterfrom
Conversation
c223928 to
ae8393a
Compare
4 tasks
apapirovski
approved these changes
Apr 10, 2019
Contributor
apapirovski
left a comment
There was a problem hiding this comment.
IMO a positive change.
Member
|
targos
approved these changes
Apr 10, 2019
FromJust() is often used not for its return value, but for its side-effects. In these cases, Check() exists, and is more clear as to the intent. From its comment: To be used, where the actual value of the Maybe is not needed like Object::Set. See: https://github.com/nodejs/node/pull/26929/files#r269256335
ae8393a to
f281035
Compare
Collaborator
devsnek
approved these changes
Apr 11, 2019
Collaborator
ZYSzys
approved these changes
Apr 12, 2019
Contributor
Author
|
Landed in 060d901 |
sam-github
added a commit
that referenced
this pull request
Apr 12, 2019
FromJust() is often used not for its return value, but for its side-effects. In these cases, Check() exists, and is more clear as to the intent. From its comment: To be used, where the actual value of the Maybe is not needed, like Object::Set. See: https://github.com/nodejs/node/pull/26929/files#r269256335 PR-URL: #27162 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Contributor
Author
|
Is it possible to make |
addaleax
added a commit
to addaleax/node
that referenced
this pull request
Apr 15, 2019
Handle possible JS exceptions that can occur by returning to JS land immediately. The motivation for this change is that `USE(….FromJust());` is an anti-pattern, and `.FromJust()` with an unused return value is superseded by `.Check()`. However, in this case, checking that the operation succeeded is not necessary. Refs: nodejs#27162
2 tasks
addaleax
added a commit
that referenced
this pull request
Apr 17, 2019
Handle possible JS exceptions that can occur by returning to JS land immediately. The motivation for this change is that `USE(….FromJust());` is an anti-pattern, and `.FromJust()` with an unused return value is superseded by `.Check()`. However, in this case, checking that the operation succeeded is not necessary. Refs: #27162 PR-URL: #27245 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Apr 23, 2019
Member
@sam-github You could file a V8 CL that does that. Seems like a good change to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FromJust() is often used not for its return value, but for its
side-effects. In these cases, Check() exists, and is more clear as to
the intent. From its comment:
To be used, where the actual value of the Maybe is not needed like
Object::Set.
See: https://github.com/nodejs/node/pull/26929/files#r269256335
I'm not dead sure this is a good idea, because Check() doesn't exist on 11.x, but on the other hand, it's
a trivial method, we could probably backport the v8 patch for it to 11.x if it's absence was painful.
Check()is much more clear in its intent, IMO, than FromJust() called just for its side-effect.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes