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

Property access at the wrong time in pure mode #2151

Closed
hotsnr opened this issue Jun 22, 2018 · 2 comments
Closed

Property access at the wrong time in pure mode #2151

hotsnr opened this issue Jun 22, 2018 · 2 comments

Comments

@hotsnr
Copy link

hotsnr commented Jun 22, 2018

 function bad(v) {
        if (v == null) {
            return null;
        }
        var a = v.a,
            b = v.b;
        if (a == null || b == null) {
            return a && b;
        }
        return v;
    }

__optimize(bad);

leads to this output

(function () {
  var _$2 = this;

  var _0 = function (v) {
    var _$0 = v.a;             // <== v can be null which is handled in input
    var _$1 = v.b;             

    var _1 = v == null;

    if (!_1) {
      var _$0 = v.a;   
      var _$1 = v.b;

      var _5 = _$0 == null;

      var _7 = _$1 == null;

      var _4 = _5 || _7;

      if (!_4) {
        var _$0 = v.a;
        var _$1 = v.b;
      }
    }

    var _B = _$0 && _$1;

    var _A = _4 ? _B : v;

    var _9 = _1 ? null : _A;

    return _9;
  };

  _$2.bad = _0;
}).call(this);
@hotsnr hotsnr changed the title Property access at the wrong time Property access at the wrong time in pure mode Jun 22, 2018
@NTillmann
Copy link
Contributor

Maybe the same root cause as #2133?

@hermanventer
Copy link
Contributor

This is an instance of a known problem with composing two forked completions. I'm currently working on the general problem.

facebook-github-bot pushed a commit that referenced this issue Aug 15, 2018
Summary:
Fixes #2151 #2222 #2279 #2393 #2399 #2404 #2411 #2414 #2415
Added a fuzz testing tool
Added test cases
Turn crash in JSON.stringify into a diagnostic
Adds a `arrayNestedOptimizedFunctionsEnabled` flag to enable nested optimized functions derived from Array.prototype methods (like `map`) and Array.from
Refactor assignment on partial or possibly deleted property
Rewrote the joining logic to always do a full join at every join point
Removed last remnants of delayUnsupportedRequires

Reviewed By: cblappert

Differential Revision: D9349841

fbshipit-source-id: 74a16dbb015777d59d23fdfde77abbe2489c292a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants