Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
Herman Venter edited this page Jun 15, 2017 · 3 revisions

might be an object that behaves badly for the in/instanceof operator

The right hand expression of an in (or instanceof) operator is an unknown value which is known to be an object, but which may defined in such a way that that an in or instanceof check could result in the invocation of an unknown method, which could cause Prepack to go wrong.

In particular, unknown methods might modify the global heap or they may throw an exception. If this should happen, then the values of the heap computed by Prepack will be incomplete or wrong, with the result that running Prepack over a program changes its runtime behavior.

In the case of the in operator, things can go wrong if the object is a TypedArray with a detached buffer. Checking if a numerical property is in the array will throw an exception in such a case. Things can also go wrong if the object is Proxy with its own "has" method. If the latter throws an exception or modifies the heap, Prepack can go wrong.

In the case of the instanceof operator, things can go wrong if the object has an @@hasInstance method of its own and this method is badly behaved.

To make this error go away, consider refining the environment model so that Prepack can figure out that the unknown object will not behave badly, for example by marking the object as simple.

Note that it is actually possible to see this error when the object is completely known to Prepack, but the left hand operand is not. This is a non essential limitation of Prepack. If you run into it please create an issue with a description of how important this is to you.

Clone this wiki locally