Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing actions - error got '}' expected ':' in function assign #12

Open
SimonGAndrews opened this issue Sep 1, 2021 · 3 comments
Open

Comments

@SimonGAndrews
Copy link
Owner

image

above error occurs when executing test\Esprunio-ESP32\test_basicActions.js in Esprunio on esp32.

@SimonGAndrews
Copy link
Owner Author

SimonGAndrews commented Sep 6, 2021

image
the above snip of the original xstate-fsm code (except the module export change) of the assign function shows where this issue is occurring. A debug output of the variables in the function when executing within Node is:
image

So the function is called with the parameter 'assignment' containing an object with the named function (redLights in this case). It appears the intent of the original code is to have the function return 'assignment' as the second property in the returned object.
Running the code in Node achieves this by expanding the contents of 'assignment' and returning the result in the second property. However Espruino doesnt seem to be expanding 'assignment' and is unhappy that it cant find the ';' in the object to be returned.

@SimonGAndrews
Copy link
Owner Author

The fix to the issue, under test, is to change the assign function code to:
image
ie adding the property name 'assignment:' to the object being returned.

looking at the return variable in the function in debug (running under Node) gives the following
image
which appears to be the same as the original code.
This change also passes the regression test. test\Node\xstate-fsm\fsm.test.js
The change overcomes the issue in Espruino on initial testing.
Further testing in Espruino required.

SimonGAndrews added a commit that referenced this issue Sep 6, 2021
@SimonGAndrews
Copy link
Owner Author

status - Leave open pending further testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant