dev_compiler icon indicating copy to clipboard operation
dev_compiler copied to clipboard

prefix op on index expr doesn't return value

Open jmesserly opened this issue 10 years ago • 0 comments

This test uses async, but I don't think that's the issue. We desugar ++v[0] without a return value, so the expect 42 fails.

    test("suffix operator + pre-increment", () {
      f() async {
        var v = [41];
        return await ++v[0];
      }
      return expect42(f());
    });

the bug seems to be here:

            let v = [41];
            return yield (() => {
              let i = 0;
              return v[dartx.set](i, dart.dsend(v[dartx.get](i), '+', 1));
            })();

Note the return v[dartx.set] line ... how can that possibly work? []= methods and setters don't need to return values...

edit: and we get undefined back out from calling the function. Array looks fine, v is [42]

jmesserly avatar Jul 23 '15 23:07 jmesserly