[quickjs-devel] Re: Bug in Object.seal() and Object.freeze()

  • From: Fabrice Bellard <fabrice@xxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Tue, 14 Jan 2020 11:09:00 +0100

Right. The regression will be fixed in the next release.

Best regards,

Fabrice.

On 1/14/20 10:59 AM, John Gardner wrote:

The ECMAScript specification states that Object.seal() <https://www.ecma-international.org/ecma-262/6.0/#sec-object.seal> and Object.freeze() <https://www.ecma-international.org/ecma-262/6.0/#sec-object.freeze> must return the object that was passed.

This is a bug in QuickJS. It isn't up for discussion when it's a clear violation of the spec.

On Tue, 14 Jan 2020 at 18:24, ian <ian@xxxxxxxxx <mailto:ian@xxxxxxxxx>> wrote:

    Hi.

    Not sure this is accurate, but a seal() or freeze() method is an
    action, it then has to return a boolean value telling if it succeeded.
    Dunno at all what a value="sealed" is, but it does not seem to me to
    be convenient.

    Regards.

    ian

    Le 14/01/2020 à 01:27, junsik park a écrit :

    Unlike previous, 2020-01-05 quickjs returns true for Object.seal()
    and Object.freeze().

    Returned value should be sealed.


    - junsik



    diff --git a/quickjs.c b/quickjs.c
    index 4c467af..99c892d 100644
    --- a/quickjs.c
    +++ b/quickjs.c
    @@ -35191,7 +35191,7 @@ static JSValue js_object_seal(JSContext
    *ctx, JSValueConst this_val,
                 goto exception;
         }
         js_free_prop_enum(ctx, props, len);
    -    return JS_TRUE;
    +    return js_object_preventExtensions(ctx, JS_UNDEFINED, 1,
    argv, 0);

      exception:
         js_free_prop_enum(ctx, props, len);

-- -- ian@xxxxxxxxx <mailto:ian@xxxxxxxxx>
    -- Développeur compulsif


Other related posts: