Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Failing nested optimized function case #2358

Closed
trueadm opened this issue Aug 2, 2018 · 1 comment
Closed

Failing nested optimized function case #2358

trueadm opened this issue Aug 2, 2018 · 1 comment
Assignees
Labels
optimized functions Issues around optimizing not global code, but additional functions priority: high react compiler

Comments

@trueadm
Copy link
Contributor

trueadm commented Aug 2, 2018

Another failing nested optimized function case:

function fn(x, y, obj, cond) {
  var arr = Array.from(x);
  var arr2 = Array.from(y);

  var a = obj.a;
  
  var res = arr.map(function(item) {
    if (cond) {
      return a;
    }
  });

  var res2 = arr2.map(function(item) {
    if (cond) {
      return a;
    }
  });

  return [res, res2];
}

__optimize(fn);

We hit an invariant with this particular case

@trueadm trueadm added priority: high react compiler optimized functions Issues around optimizing not global code, but additional functions labels Aug 2, 2018
@trueadm
Copy link
Contributor Author

trueadm commented Aug 2, 2018

Like the other issue, if I use explicit nested optimized functions:

function fn(x, y, obj, cond) {
  var arr = x;
  var arr2 = y;

  var a = obj.a;
  
  var mapper1 = function(item) {
    if (cond) {
      return a;
    }
  };
  __optimize(mapper1);
  var res = arr.map(mapper1);

  var mapper2 = function(item) {
    if (cond) {
      return a;
    }
  };
  __optimize(mapper2);
  var res2 = arr2.map(mapper2);

  return [res, res2];
}

__optimize(fn);

Update: this now works with the latest changes on master. Note that the logic in this test case is different from that of above, as the map function and the array are both havoced.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
optimized functions Issues around optimizing not global code, but additional functions priority: high react compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants