babel-plugin-proxy icon indicating copy to clipboard operation
babel-plugin-proxy copied to clipboard

assigning to r value

Open zwhitchcox opened this issue 7 years ago • 7 comments

| 
| var getId = exports.getId = function getId() {
|   return globalGetInterceptor(global, "id")++;
| };

So, this is the error, not really sure how to fix it

original code:

export const global = {
  id: 0
}

export const getId = (): number => global.id++

zwhitchcox avatar May 09 '17 21:05 zwhitchcox

Oh, ok, I guess the problem is the loader doesn't account for unary expressions...that should be easy enough though, I guess

zwhitchcox avatar May 09 '17 21:05 zwhitchcox

So, idk why, but it's working in the test cases, so I guess I must be doing something wrong....will report back if something goes wrong

zwhitchcox avatar May 10 '17 01:05 zwhitchcox

So, this is still a problem

zwhitchcox avatar May 10 '17 15:05 zwhitchcox

@zwhitchcox can you make sure that this is not related to flow annotations? I mean : number thing

krzkaczor avatar May 10 '17 15:05 krzkaczor

Yeah, verified with this test:

  it('should not mess up update expressions', function () {
    const code = `
      var x = { i: 0 }
      console.log(x.i++)
      console.log(++x.i)
    `
    const runLogs = compileAndRun(code)
    expect(runLogs).to.be.deep.eq([0, 2])
  })

zwhitchcox avatar May 10 '17 15:05 zwhitchcox

@zwhitchcox nice, thanks! I am super busy now but I will try to review your PR and take a look at that issue later today :)

krzkaczor avatar May 10 '17 15:05 krzkaczor

Ok, thanks, I'm working on it too

zwhitchcox avatar May 10 '17 15:05 zwhitchcox