This commit is contained in:
Dustin Swan 2026-02-12 22:05:15 -07:00
parent 8c20a29b54
commit 68f4fbe9b3
No known key found for this signature in database
GPG key ID: 30D46587E2100467
5 changed files with 42 additions and 43 deletions

View file

@ -259,11 +259,19 @@ function valueToAst(value: any): AST {
// Functions
if (typeof value === 'function') {
if (value._astId !== undefined) {
return astRegistry.get(value._astId)!;
if (value._astId === undefined) {
throw new Error('Cannot persist native functions');
}
const ast = astRegistry.get(value._astId)!;
if (!ast) {
console.error('Registry size:', astRegistry.size, 'Looking for:', value._astId,
'Function:', value.toString().slice(0, 200));
throw new Error(`AST registry miss for _astId ${value._astId}`);
}
throw new Error('Cannot serialize function without _astId');
return ast;
}
throw new Error(`Cannot convert to AST: ${typeof value}`);