After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686864 - object_instance_props_to_g_parameters should do more check on argv
object_instance_props_to_g_parameters should do more check on argv
Status: RESOLVED OBSOLETE
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
: 774663 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-10-25 13:10 UTC by Guillaume Desmottes
Modified: 2018-01-27 11:51 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Guillaume Desmottes 2012-10-25 13:10:59 UTC
I just wasted one day of my life debugging a very weird bug in some js code. Turned out I wrote "new Clutter.BindConstraint(stage, Clutter.BindCoordinate.SIZE, 0);" instead of "Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.SIZE, 0);" (yeah I suck at Javascript...).

All this pain could have been avoided if gjs would have raised an exception rather than silently accepting invalid arguments. 

object_instance_props_to_g_parameters should raise an exception if:
- argc > 1
- argv[0] is not dictionnary
Comment 1 Giovanni Campagna 2012-10-25 17:07:01 UTC
Well, we do allow more parameters than requested everywhere else (as that's the standard JS convention), and we have no way to check if an object is a "dictionary" or not (other than checking for __proto__ == Object.prototype, but it looks wrong to me).
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-10-25 18:20:53 UTC
(In reply to comment #1)
> Well, we do allow more parameters than requested everywhere else (as that's the
> standard JS convention)

Note that it's probably worthwhile to exclude it otherwise. This is being revisited for ES.next and having explicit rest parameters and splat instead.
Comment 3 Guillaume Desmottes 2012-10-26 07:51:30 UTC
(In reply to comment #1)
> Well, we do allow more parameters than requested everywhere else (as that's the
> standard JS convention),

What's the rationale for this? This sounds like the perfect way to shoot yourself in the foot.

> and we have no way to check if an object is a
> "dictionary" or not (other than checking for __proto__ == Object.prototype, but
> it looks wrong to me).

I'm sure JS can't be that retarded. What's wrong with checking __proto__ exactly?
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-10-26 12:47:12 UTC
(In reply to comment #3)
> (In reply to comment #1)
> > Well, we do allow more parameters than requested everywhere else (as that's the
> > standard JS convention),
> 
> What's the rationale for this? This sounds like the perfect way to shoot
> yourself in the foot.

For ECMAScript in general? A lack of actual syntax for actual varadiac parameters. I think it's the right thing to violate JS convention here.

> > and we have no way to check if an object is a
> > "dictionary" or not (other than checking for __proto__ == Object.prototype, but
> > it looks wrong to me).
> 
> I'm sure JS can't be that retarded. What's wrong with checking __proto__
> exactly?

I think we've had cases before where we pass actual instances of classes to initializers to use them as property bags.
Comment 5 Philip Chimento 2016-11-18 08:16:46 UTC
*** Bug 774663 has been marked as a duplicate of this bug. ***
Comment 6 GNOME Infrastructure Team 2018-01-27 11:51:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gjs/issues/63.