Closed Bug 814892 Opened 10 years ago Closed 9 years ago

Harmony direct proxies: "get" trap throws unexpectedly

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: tomvc.be, Assigned: till)

References

Details

(Whiteboard: [js:p2])

Attachments

(1 file)

Executing the following script in Nightly 20.0a1 (2012-11-24) throws unexpectedly:

function test() {
  var t = Object.freeze({x:1});
  var p = new Proxy(t,{
    get: function(target, name, rcvr) {
      return target[name];
    }
  });
  console.log(p.x);
}

observed behavior:
TypeError: proxy must report the same value for a non-writable, non-configurable property

Expected: p.x should just return 1

This has to do with the invariant checks in direct proxies. The proxy should only throw this error if the "get" trap of the proxy returns a result that is inconsistent with the value of the target, but in this case the result should be perfectly consistent.

The bug only occurs when the target of the proxy is frozen.

Note: it would be helpful if the name of the offending property were included in the error string of the TypeError.
Blocks: 703537
Assignee: general → ejpbruel
Whiteboard: [js:p2]
The target object doesn't have to be frozen:
function test() {
    let o = Object.create(Object.prototype, { p: { value: 5 } });
    new Proxy(o, { get: function(t, n) t[n] }).p
}
test()
/*
Exception: proxy must report the same value for a non-writable, non-configurable property
test@Scratchpad/3:3
@Scratchpad/3:5
*/
Assignee: ejpbruel → till
Status: NEW → ASSIGNED
Comment on attachment 8349060 [details] [diff] [review]
Actually compare the right values when making sure a proxy [[Get]] trap returns the correct value

Thanks for finding this. r=me.
Attachment #8349060 - Flags: review?(efaustbmo) → review+
And after a short 13 months, we've actually applied the one-token change needed to fix this. So sorry about the delay! And thanks, :Fallen, for the ping.

remote:   https://hg.mozilla.org/integration/mozilla-inbound/rev/5bcd468384a8
https://hg.mozilla.org/mozilla-central/rev/5bcd468384a8
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
You need to log in before you can comment on or make changes to this bug.