mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-11-23 23:13:43 +03:00
Page:
PP0026
Pages
Compiler assumptions
Effects
Fuzzer
Home
Marking an object as simple
Optimized Functions
Optimized function
PP0002
PP0003
PP0004
PP0005
PP0006
PP0007
PP0008
PP0009
PP0010
PP0011
PP0012
PP0013
PP0014
PP0015
PP0016
PP0017
PP0018
PP0019
PP0020
PP0021
PP0022
PP0023
PP0024
PP0025
PP0026
PP0027
PP0028
PP0029
PP0030
PP0031
PP0032
PP0033
PP0034
PP0035
PP0036
PP0037
PP0038
PP0040
PP0041
PP0043
PP0045
PP1001
PP1002
PP1003
PP1004
PP1005
PP1006
PP1007
PP1008
PP1009
PP8000
PP9000
Partially unknown object
Prepack Concepts
Prepack diagnostics
React Compiler
Research papers citing Prepack
Suggested reading
Tips and tricks on how to debug things as a Prepack developer
Unknown Abstract function value
Unknown Abstract value
Well behaved property
4
PP0026
Dan Abramov edited this page 2018-02-21 23:13:20 +00:00
Mutating an object with unknown properties, after some of those properties have already been used, is not yet supported
To a certain extent, Prepack can handle partially unknown objects.
For example, even if obj
is partially unknown, Prepack can still process code like this:
var target = {};
Object.assign(target, obj);
However, since Prepack doesn't know all the properties of obj
, it can't know what the target
object is going to look like after this call. In this case, Prepack emits Object.assign()
in the result code instead of evaluating it at compile time.
Currently, this is only safe to do if target
doesn't get mutated further down the line. For example, code like this will cause a compile error:
var target = {};
Object.assign(target, obj);
target.hello = 'world';
In the future, Prepack may be able to handle this case better by "snapshotting" the state of target
before it was passed to Object.assign
. However, this is not supported yet.