Skip to content

src: replace FromJust() with Check() when possible

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading