Closed feyzo closed 6 years ago
Error is in: <foreach item="'continue'" index="Var3" array="Var5">
@item and @index should be valid javascript identifiers.
Use the same technique that you're using to lint <assign>
@array should be valid js expression.
I fixed the second foreach with illegal item. This test is now failing.
Cause of the failure is because array="Var4" on first foreach is not an array and test is expecting an error raised in that state. I think compiler is not going to be able to understand that completely. We can use dataModelAccumulators to check if the initial value is array or not.
But after datamodel declaration and before foreach, we can do <assign location="Var4" expr="[1,2,3]" />
and change Var4 to an array. I think that is why we need a check on the runtime.
I'm thinking of editing else here to raise error. https://github.com/jbeard4/SCION/blob/2.0.0-w3c-ecma/lib/compiler/scjson-to-module.js#L473-L485
What do you think?
We need a runtime check. We implement a proprietary extension to the SCXML spec, where if an Array is not used as the array
variable, the compiler assumes it is an object, and iterates over the object keys and values:
https://github.com/jbeard4/SCION/blob/2.0.0-w3c-ecma/lib/compiler/scjson-to-module.js#L479-L484
What we need is runtime logic that says that if the value for array
is not an array, we raise an error event using this.raise
.
So are we going to do something like this?
if(Array.isArray(array))
for(i=0;....)
else if(what to do here?)
for(index in array)
else
raise error.
How are we going to check the second if? I did some tests here: http://jsbin.com/futigi/7/edit?js,output
Like:
if(Array.isArray(array))
for(i=0;....)
else
raise error.
I think we need this in order to be compliant with the spec.
Module: https://gist.github.com/feyzo/042ac93eb63637317d07 Log: https://gist.github.com/feyzo/0b437ff2f4eb7f58cc44
The test ends on s1 state without any transition or event on the queue i think.
In the module, raise_line_27_column_61
is meant to queue up another error.execution
event, but it looks like this isn't happening. Not sure why - next step would be to trace it in a debugger and look at the inner event queue at the end of the each big-step.
https://github.com/jbeard4/scxml-test-framework/tree/master/test/scxml-test-framework/test/w3c-ecma/test152.txml.scxml
Error
Data:
scxml:
JSON: