TypeError: Cannot read properties of null (reading 'toXML')

Steps

  1. Drag and drop the following blocks to the Snap! editor to import the following blocks:
    a script pic (1)

  2. Run that script.

  3. Try to export the project.

  4. The error (TypeError: Cannot read properties of null (reading 'toXML')) appears.

I don't know how this exactly happened, but if a bug can be fixed, this could be, too.

what r u tryting to make

I'm trying to make a converter project. When I have done the project and try to save it, it got stuck. Exporting it yields the error.

Huh, strange, exporting worked fine for me.
(Running on ChromeOS on a Chromebook)

?wym

I guess you need to run the script first before exporting. Looks like that I get the error.

I'm on an HP laptop on Windows 11.

It's a project that allows to convert units to other units, and even create your own converters. It'll be released soon.

Thats what I did, but exporting still worked fine. It could potentially be a Windows issue..
I do have a Windows 11 computer I could try exporting it on here in a bit

Works for me (MacOS, Chrome).

Can no longer reproduce now. Weird.

send link

I can reproduce it like this.

  1. Import the script into snap
  2. Create a variable named a (a global or local variable, one's content that would be saved in the project)
  3. Run the script
  4. Try to export the project

did you send the project yet?

The project is WIP (work in progress). The bug blocks sharing somehow unless the bug is fixed.

@OP, you may mark the variable "a" as "transient" to be able to save/export.


Minimal reproducible example ( "say for" is "required" to trigger the error)
test script pic

Edit: minimal example
test script pic (2)

JS Console after save/export.

gui.js?version=2024-04-24:5743 Uncaught TypeError: Cannot read properties of null (reading 'toXML')
    at store.js?version=2023-07-27:2530:46
    at Array.reduce (<anonymous>)
    at Context.toXML (store.js?version=2023-07-27:2529:21)
    at XML_Serializer.store (store.js?version=2023-07-27:128:19)
    at Context.toXML (store.js?version=2023-07-27:2544:40)
    at XML_Serializer.store (store.js?version=2023-07-27:128:19)
    at store.js?version=2023-07-27:2133:46
    at Array.reduce (<anonymous>)
    at VariableFrame.toXML (store.js?version=2023-07-27:2110:35)
    at XML_Serializer.store (store.js?version=2023-07-27:128:19)

i need the project to see the bug

i cant replicate the formula block

See @dardoro's post:

i already saw the post