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 21, 2017 · 1 revision

might be a symbol or an object with an unknown valueOf or toString or Symbol.toPrimitive method

When an unknown value is used in an expression that will attempt to convert the value to a number, things can go wrong if the value turns out to be a Symbol or an object with a custom valueOf or toString or Symbol.toPrimitive method.

In particular, converting a symbol to Number throws a TypeError and calling a custom method might modify the global heap or may result in 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.

To make this error go away, consider refining the environment model so that Prepack can figure out that converting this value will not cause such changes. For example, by using an expressions such as __abstract("number") rather than just __abstract() for values that are known to always be numbers.

Clone this wiki locally