Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

Bug in computeTopLevelExpressions for o.p += ... #80

Open
esbena opened this issue Nov 17, 2014 · 0 comments
Open

Bug in computeTopLevelExpressions for o.p += ... #80

esbena opened this issue Nov 17, 2014 · 0 comments

Comments

@esbena
Copy link

esbena commented Nov 17, 2014

It seems that that astUtil.computeTopLevelExpressions has a bug.
The following test fails if it is added to topLevelExprTests.js:

it('should handle property increment', function() {
    checkCode("var o = {p: 42}; o.p += 37;",  [25, 49]); // yields [25, 49, 41]
});

Clearly there should only be two top level expressions in that code.

The instrumented code that astUtil.computeTopLevelExpressions operates on is this:

var o = J$.W(25, 'o', J$.T(17, { p: J$.T(9, 42, 22, false) }, 11, false), o, false, true);
J$.A(49, J$.R(33, 'o', o, false, true), 'p', '+')(J$.T(41, 37, 22, false));

Reporting 41 as a top level expression happens because the implementation of astUtil.computeTopLevelExpressions assigns a nesting depth of zero to J$.T(41, …) because it does not recognize the nestedness of J$.A(…)(J$.T(41, …)), an additional case is needed for that pattern.

(I do have a simple fix, I will do a pull request later)

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