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

Abstract empty values should fail RequireObjectCoercible #2515

Conversation

calebmer
Copy link
Contributor

This fixes a bug it took me a while to track down. Unfortunately creating a repro was really difficult. I was observing the following invariant in Reference being triggered.

https://github.com/facebook/prepack/blob/fddfc6f0c52fa8f49fb0cb1208f34cefcb95dca3/src/environment.js#L1425-L1431

Digging in, the bad base was a deep conditional AbstractValue where all the leaf nodes were EmptyValue and __bottomValue. (Constructed from a number of try/catch/throws.) This AbstractValue should have simplified to just EmptyValue then RequireObjectCoercible() should have thrown a runtime TypeError after seeing the EmptyValue. This is what I observed in local tests when trying to reproduce this issue.

After looking at the error in the large React Native bundle I’m working in I discovered that the simplifier was throwing an error since the simplification count was exceeded. This is fine and normal. The issue was that RequireObjectCoercible() does not handle complex empty AbstractValues well. If failing simplification is a normal part of Prepack operation we should make sure methods like RequireObjectCoercible() can handle complex AbstractValues as well as simple ones.

This PR does that.

Copy link
Contributor

@NTillmann NTillmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems logical wrong to me. The empty value is not undefined.

@hermanventer
Copy link
Contributor

The empty value is supposed to be unreachable, so it does not really matter if it is modeled as undefined in this situation. I do plan to get rid of this use of the empty value in the near future, which will make this into a non issue. Meanwhile, I think this change is fine.

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into the same issue this morning. Landing this as it LGTM.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trueadm is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants