overlookmotel / livepack

Serialize live running code to Javascript
MIT License
42 stars 1 forks source link

Tests for functions only referred to by other functions in same scope with extra properties #530

Open overlookmotel opened 11 months ago

overlookmotel commented 11 months ago

The following works, but I'm not sure if there are tests for it:

Input:

const x = 1;
function f() { return x; }
function f2() { return x + f.y; }
f.y = 100;
export default f2;

Output:

const scopeIndex = ((x, f$0) => [
  f$0 = function f() { return x; },
  function f2() { return x + f$0.y; }
])(1);
Object.assign(scopeIndex[0], {y: 100});
export default scopeIndex[1];

If there are not tests already, add some. It would be easy for #426 to break this.