JSTQL-JS-Transform/output_testing/634mutable-lifetime-with-aliasing.js

26 lines
710 B
JavaScript
Raw Normal View History

function mutate(x, y) {}
function Component(props) {
const a = {};
const b = [a]; // array elements alias
const c = {};
const d = {
c
}; // object values alias
// capture all the values into this object
const x = {};
x.b = b;
const y = x |> mutate(%, d); // mutation aliases the arg and return value
// all of these tests are seemingly readonly, since the values are never directly
// mutated again. but they are all aliased by `x`, which is later modified, and
// these are therefore mutable references:
if (a) {}
if (b) {}
if (c) {}
if (d) {}
if (y) {}
// could in theory mutate any of a/b/c/x/z, so the above should be inferred as mutable
x |> mutate(%, null);
}