Skip to content
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

object rest doesn't call Get() #5095

Closed
gsathya opened this issue Jan 11, 2017 · 7 comments
Closed

object rest doesn't call Get() #5095

gsathya opened this issue Jan 11, 2017 · 7 comments
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Object Rest/Spread

Comments

@gsathya
Copy link
Member

gsathya commented Jan 11, 2017

Input Code

var x = {
  get a() { throw new Error(); },
};

(() => { var { ...y} = x; })();

REPL

Babel Configuration (.babelrc, package.json, cli command)

Presets - ES6- stage3

Expected Behavior

→ ./out.gn/x64.debug/d8 -harmony-object-rest-spread 
V8 version 5.7.0 (candidate)
d8> var x = { get a() { throw new Error(); } };
undefined
d8> (() => { var { ...y } = x; })();
(d8):1: Error
var x = { get a() { throw new Error(); } };
                    ^
Error
    at Object.get a [as a] ((d8):1:27)
    at (d8):1:19
    at (d8):1:30

Current Behavior

No error

Possible Solution

_objectWithoutProperties does not do ? Get(from, nextKey)

@gsathya gsathya changed the title object rest doesn't call from.[[OwnPropertyKeys]]() object rest doesn't call Get() Jan 11, 2017
@danez
Copy link
Member

danez commented Jan 17, 2017

I just checked the transpiled code of the repl in node 6 and was not able to reproduce. The Error was thrown as expected.

Though it seems the repl is somehow misbehaving here and not evaluating the code correctly.

@gsathya Can you confirm this?

@danez danez added i: invalid and removed i: bug labels Jan 17, 2017
@danez
Copy link
Member

danez commented Jan 17, 2017

Oh I found the issue, it seems the repl is catching the Error and printing it. But as in the example the Error has no msg nothing is printed.

@hzoo hzoo added i: bug and removed i: invalid labels Jan 17, 2017
@hzoo
Copy link
Member

hzoo commented Jan 17, 2017

helpers.objectWithoutProperties = template(`
(function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
})
`);
- doesn't handle getters

@danez
Copy link
Member

danez commented Jan 18, 2017

I think it does.

var x = {
  get a() { return 1; },
};

(() => { var { ...y} = x; console.log(y); })();

This code is printing

Object {
  "a": 1
}

And I'm not sure about the specs, but that seems okay, unless the whole getter should be copied over.

@xtuc
Copy link
Member

xtuc commented Jan 18, 2017

If i'm not wrong this is calling the getter. I wasn't able to reproduce this as well.

@gsathya
Copy link
Member Author

gsathya commented Jan 18, 2017

And I'm not sure about the specs, but that seems okay, unless the whole getter should be copied over.

The getter should not be copied over. { "a" : 1 } is correct.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Object Rest/Spread
Projects
None yet
Development

No branches or pull requests

5 participants