JS: add explanation to inline/arrayLiteralAliasing.kt test

This commit is contained in:
Alexey Andreev
2016-09-13 17:28:46 +03:00
parent a9330057cc
commit dd062bfd6d
@@ -1,3 +1,29 @@
/*
This tests that variables (aliases) are created for array literals.
Let's say we have the following JS code:
function f(a) {
a.push(0);
return a;
}
// ...
console.log(f([]));
In this case copying f's argument a without creating a variable is incorrect because it would produce the following code:
[].push(0);
console.log([]);
This is the correct version:
var a = [];
a.push(0);
console.log(a);
The test was created because we don't want to create aliases for literals.
However in our class hierarchy JsArrayLiteral is subclass of JsLiteral,
which makes very easy to implement incorrect aliasing logic.
*/
package foo
// CHECK_NOT_CALLED: moveTo