Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

desugaring bug in with #1

Open
arjunguha opened this issue Nov 7, 2011 · 0 comments
Open

desugaring bug in with #1

arjunguha opened this issue Nov 7, 2011 · 0 comments

Comments

@arjunguha
Copy link
Member

) We found that the "with" desugaring presented in the paper does not capture the implementation. The desugared "with" example in page 12 of the ECOOP 2010 paper is as follows:

function(x, obj) {
if (obj.hasOwnProperty("x")) { obj.x = 50 }
else { x = 50 }
if ("y" in obj) { return obj.y }
else { return window.y } }

but the corresponding implementation in DesugarWith.hs uses only the hasOwnProperty version not the "in" operator.

  1. Moreover, the implementation does not preserve the ECMAScript semantics. Unlike [[HasProperty]], the hasOwnProperty method does not consider objects in the prototype chain. Therefore, the desugaring using the hasOwnProperty method does not preserve the ECMAScript semantics. For example, the following code:

    var z = 50;
    var cons=function(){
    this.x=3;
    this.y=2;};
    var obj = {z:2};
    cons.prototype=obj;
    var newobj = new cons();
    with (newobj) actual=z;
    print(actual);

should print 2 according to ECMAScript, but the desugared code via LambdaJS prints 50. Note that both SpiderMonkey and JSC also print 2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant