eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
398 stars 62 forks source link

Implement or disallow ++ on indexed expressions #7426

Open jvasileff opened 6 years ago

jvasileff commented 6 years ago

The typechecker allows a[i]++, but this fails on the backends:

Note that the typechecker does not allow a[i] += 1.

Full example:

shared void run() {
    value a = Array { 0, 0, 0 };
    variable Integer i = 0;
    a[i++]++;
    print(a); // should be { 1, 0, 0 }
    print(i); // should be 1
}
xkr47 commented 5 years ago

I would vote to implement both.