This is not a great example, but it uncovers an issue I saw a lot of: “all native function values should be intrinsics.” Our visitor expects that all FunctionValue
s which make it to visitValueFunction
are not NativeFunctionValue
s since these should be intrinsics.
https://github.com/facebook/prepack/blob/b0516b49ea50d8ce81af6d0518e8ec071866201a/src/serializer/ResidualHeapVisitor.js#L1025-L1035
However, NativeFunctionValue
s may have an undefined
intrinsicName
. Which makes them not an intrinsic!
https://github.com/facebook/prepack/blob/b0516b49ea50d8ce81af6d0518e8ec071866201a/src/values/NativeFunctionValue.js#L36-L45
You can see an example of this here:
https://github.com/facebook/prepack/blob/e170c37aaa996c75cb166671c5b6af442a227d5c/src/intrinsics/ecma262/ObjectPrototype.js#L130-L163
var ThrowTypeError = Object.getOwnPropertyDescriptor(
(function() {
"use strict";
return arguments;
})(),
"callee"
).get;
ThrowTypeError(); // Expected to throw `TypeError`
Invariant Violation: all native function values should be intrinsics
This is likely a bug in Prepack, not your code. Feel free to open an issue on GitHub.
at invariant (/Users/calebmer/prepack/lib/invariant.js:24:15)
at ResidualHeapVisitor.visitValueFunction (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:509:28)
at _enqueueWithUnrelatedScope (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:1026:45)
at _withScope (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:1255:19)
at ResidualHeapVisitor._withScope (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:208:7)
at runGeneratorAction (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:1254:18)
at ResidualHeapVisitor._visitUntilFixpoint (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:1310:11)
at ResidualHeapVisitor.visitRoots (/Users/calebmer/prepack/lib/serializer/ResidualHeapVisitor.js:1196:10)
at statistics.deepTraversal.measure (/Users/calebmer/prepack/lib/serializer/serializer.js:195:68)
at PerformanceTracker.measure (/Users/calebmer/prepack/lib/statistics.js:91:14)
at ast (/Users/calebmer/prepack/lib/serializer/serializer.js:195:34)
at statistics.total.measure (/Users/calebmer/prepack/lib/serializer/serializer.js:230:9)
at PerformanceTracker.measure (/Users/calebmer/prepack/lib/statistics.js:91:14)
at Serializer.init (/Users/calebmer/prepack/lib/serializer/serializer.js:148:35)
at prepackSources (/Users/calebmer/prepack/lib/prepack-standalone.js:71:33)
at compileSource (/Users/calebmer/prepack/scripts/debug-fb-www.js:92:18)
at compileFile (/Users/calebmer/prepack/scripts/debug-fb-www.js:129:31)
at <anonymous>