{ "id": "173965", "key": "TIMOB-27301", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2019-07-31T14:02:22.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [ { "id": "20791", "name": "Release 8.0.2", "archived": false, "released": true, "releaseDate": "2019-06-18" }, { "id": "20412", "name": "Release 8.1.0", "archived": false, "released": true, "releaseDate": "2019-08-13" }, { "id": "20827", "name": "Release 8.2.0", "archived": false, "released": true, "releaseDate": "2019-09-19" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-07-31T15:29:16.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13103", "name": "CLI", "description": "Node-based command line interface" } ], "description": "h5.Description\r\n\r\nWhen using a for loop in the top level scope (i.e. not in a function) of an app.js or alloy.js file if the variable declaration used is a block scoped variable (const/let) the below error will be thrown. This is because we try to use add the level to the global scope, but as it is block scope we can't reference it outside of the for loop.\r\n\r\n*workaround*: Use {{var}} to declare the variable, or move the code into a function and call that.\r\n\r\n*Note*: I believe by default this will only be seen on Android as babel will convert const/let to var on iOS\r\n\r\n{code}\r\nERROR] TiExceptionHandler: (main) [218,218] /app.js:29\r\n[ERROR] TiExceptionHandler: }global.col = col;\r\n[ERROR] TiExceptionHandler: ^\r\n[ERROR] TiExceptionHandler: ReferenceError: col is not defined\r\n{code}\r\n\r\nh5.Steps to reproduce\r\n\r\n1. Add the below code to your app.js\r\n{code}\r\nfor (const number of [ 1, 2,3 ]) {\r\n console.log(number);\r\n}\r\n{code}\r\n2. Build to android\r\n\r\nh5.Actual\r\n\r\nApp will crash with above error\r\n\r\nh5.Expected\r\n\r\nApp should not crash", "attachment": [], "flagged": false, "summary": "CLI: Block scoped variables in for loops are attempted to be added to the global scope", "creator": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "subtasks": [], "reporter": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "environment": "SDK: 8.0.2.GA, 8.1.0.v20190726095146, 8.2.0.v20190725161133", "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }