foreach fails in strict mode due to undeclared shallow array name variable
Created by: mattoshry
This crops up when the app that hosts scion is run in use strict
mode.
<datamodel>
<data id="arr" expr="[10, 20, 30]"/>
<data id="current"/>
<data id="idx"/>
</datamodel>
<foreach array="arr" item="current" index="idx">
<log expr="'current: ' + current + ', idx: ' + idx" label="TEST"/>
</foreach>
$scionArray_31 is not defined
The issue is here: https://github.com/jbeard4/SCION/blob/2424a0a4c7dd60ad15d7e574a8764ae976051fff/lib/compiler/scjson-to-module.js#L509
A fix:
var forEachContents =
- shallowArrayName + ' = ' + arr + ';\n'+
+ 'var ' + shallowArrayName + ' = ' + arr + ';\n'+