V8_WARN_UNUSED_RESULT on DefineOwnProperty?

60 views
Skip to first unread message

Mark Logan

unread,
Jun 3, 2016, 1:02:22 PM6/3/16
to v8-users
I'm migrating some code to v8 5.0.71 (node v6.1.0), and replacing deprecated calls to ForceSet with DefineOwnProperty/CreateDataProperty.

I'm a little confused as to why V8_WARN_UNUSED_RESULT is present in these declarations, when it wasn't present for ForceSet. Is there some new reason why I should not ignore the return value? Or, is ignoring the return value from DefineOwnProperty (or CreateDataProperty) no more dangerous than it was to ignore the return value from ForceSet?

Thanks,
Mark

Ben Noordhuis

unread,
Jun 3, 2016, 1:27:58 PM6/3/16
to v8-users
I believe V8_WARN_UNUSED_RESULT didn't exist when ForceSet() was
added. Ignoring the return value is probably no more dangerous, but:

1. DefineOwnProperty() fails when you try to set a property with a
setter that throws an exception.

2. CreateDataProperty() and DefineOwnProperty() fail when the target
object is not configurable, not extensible, frozen or sealed.

IOW, there are quite a few failure modes. You almost always want to
check whether the operation succeeded and did what you thought it did.

Jochen Eisinger

unread,
Jun 8, 2016, 10:52:01 AM6/8/16
to v8-users
The reason we added V8_WARN_UNUSED_RESULT was that ignoring an exception will lead to lots of unexpected and hard to debug behavior. This annotation helps embedders to not miss any place where you have to check for an exception.

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages