NeilFraser / JS-Interpreter

A sandboxed JavaScript interpreter in JavaScript.
Apache License 2.0
1.96k stars 352 forks source link

The Serialization Demo page is not working #222

Closed jcbaillie closed 2 years ago

jcbaillie commented 2 years ago

Go to: https://neil.fraser.name/software/JS-Interpreter/demos/serialize.html

Follow the instruction on the page to test the feature. The code throws an exception and fail:

Uncaught TypeError: Unknown type: [object Object]
    at serialize (serialize.js:268)
    at serializeButton (serialize.html:27)
    at HTMLButtonElement.onclick (serialize.html:126)

I'm not sure this is localized to the example on this page, or if it's a regression in the library in general. I've tested the issue is present on the latest Chrome, Firefox, Edge.

NeilFraser commented 2 years ago

Confirmed. Definitely localized to the serialization demo. Working on it...

NeilFraser commented 2 years ago

Regression tests show that this started failing at https://github.com/NeilFraser/JS-Interpreter/commit/c7ac40d4f1116fd71f8d768742708c3a70378077

NeilFraser commented 2 years ago

Reloved with https://github.com/NeilFraser/JS-Interpreter/commit/d94f9332ef379ce3f6a6d778b7b883f680ff4948

A recent change added some new location data to the AST, which the serializer didn't know how to serialize. No need to recompile, this is entirely in the serializer code.

Thanks for raising the issue @jcbaillie