-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
src: replace FromJust() with Check() when possible #27162
Conversation
c223928
to
ae8393a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO a positive change.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSLGTM
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
Landed in 060d901 |
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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]>
Is it possible to make |
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
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
@sam-github You could file a V8 CL that does that. Seems like a good change to me. |
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