{ "id": "101314", "key": "ALOY-273", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "14632", "description": "Alloy 0.3.2", "name": "Alloy 0.3.2", "archived": false, "released": true, "releaseDate": "2012-11-16" }, { "id": "14600", "description": "2012 Sprint 23", "name": "2012 Sprint 23", "archived": true, "released": true, "releaseDate": "2012-11-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-11-15T16:09:28.000+0000", "created": "2012-09-17T06:21:35.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [ { "id": "14171", "description": "", "name": "2012 Sprint 19", "archived": true, "released": true, "releaseDate": "2012-09-24" } ], "issuelinks": [ { "id": "22319", "type": { "id": "10020", "name": "Depends", "inward": "is dependent of", "outward": "depends on" }, "inwardIssue": { "id": "101321", "key": "ALOY-274", "fields": { "summary": "Improve optimizer.js code and testing", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "23109", "type": { "id": "10020", "name": "Depends", "inward": "is dependent of", "outward": "depends on" }, "inwardIssue": { "id": "105047", "key": "ALOY-393", "fields": { "summary": "Enable optimizer.js", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } }, { "id": "22782", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "104946", "key": "ALOY-385", "fields": { "summary": "Standardize unit testing for optimizer.js", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": null, "updated": "2018-03-07T22:26:10.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "The following code ends in error:\r\n\r\n{code:javascript}\r\nif(Ti.Platform.osname != 'android') \r\n activityWindow.show();\r\nelse\r\n activityIndicator.show();\r\n{code}\r\n\r\nhere's the error:\r\n\r\n{code}\r\n[INFO] Copying builtin /usr/local/lib/node_modules/alloy/Alloy/builtins/string.js to /Users/tlukasavage/Development/alloy/test/projects/Harness/Resources/alloy/string.js\r\nnode.js:201\r\n throw e; // process.nextTick error, or 'error' event on first tick\r\n ^\r\nTypeError: Cannot call method 'apply' of undefined\r\n at walk (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:226:36)\r\n at doit (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:2039:37)\r\n at /usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:2056:72\r\n at redo_if (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:827:30)\r\n at Array. (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:869:43)\r\n at walk (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:221:47)\r\n at /usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:880:24\r\n at Object.with_walkers (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:249:27)\r\n at prepare_ifs (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:863:18)\r\n at /usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:1407:31\r\n at Object.with_walkers (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:249:27)\r\n at Object.ast_squeeze (/usr/local/lib/node_modules/alloy/Alloy/uglify-js/lib/process.js:1306:18)\r\n at Object.formatAST (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:736:12)\r\n at Object.makeRequiresRelative (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/requires.js:132:12)\r\n at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:489:26\r\n at Array.forEach (native)\r\n at Function. (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:11:39)\r\n at optimizeCompiledCode (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:483:4)\r\n at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:176:2\r\n at Object. (/usr/local/lib/node_modules/alloy/Alloy/alloy.js:101:44)\r\n at Module._compile (module.js:441:26)\r\n at Object..js (module.js:459:10)\r\n at Module.load (module.js:348:31)\r\n at Function._load (module.js:308:12)\r\n at Module.require (module.js:354:17)\r\n at require (module.js:370:17)\r\n at Object. (/usr/local/lib/node_modules/alloy/bin/alloy:3:1)\r\n at Module._compile (module.js:441:26)\r\n at Object..js (module.js:459:10)\r\n at Module.load (module.js:348:31)\r\n at Function._load (module.js:308:12)\r\n at Array.0 (module.js:479:10)\r\n at EventEmitter._tickCallback (node.js:192:40)\r\n[ERROR] Alloy compile failed\r\n[ERROR] Error: Traceback (most recent call last):\r\n File \"/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.1.1.GA/iphone/builder.py\", line 1115, in main\r\n p.compile(compiler_config)\r\n File \"/Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/plugin.py\", line 62, in compile\r\n sys.exit(retcode)\r\nSystemExit: 1\r\n{code}\r\n\r\nThe issue us resolved simply by adding curly braces to the code:\r\n\r\n{code:javascript}\r\nif(Ti.Platform.osname != 'android') {\r\n activityWindow.show();\r\n} else {\r\n activityIndicator.show();\r\n}\r\n{code}\r\n\r\nWe need to dig in and figure out why uglifyjs doesn't handle this properly.", "attachment": [], "flagged": false, "summary": "uglifyjs improperly handles if/else without curly braces", "creator": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "219240", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It appears as though the optimizer.js code is failing on trying to optimize platform comparisons when encountering this syntax. It is not an error with uglifyjs, but with how the AST is being manipulated.\r\n\r\nAdded a failing test to the optimizer test suite. Will see if I can make it pass.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-17T07:09:30.000+0000", "updated": "2012-09-17T07:09:30.000+0000" }, { "id": "219243", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Finding a number of other invalida cases with the optimizer. I'm going to spend some time with it, but I may need to disable the \"if\" and \"var\" optimizing part of the AST optimizing if this takes too long. Compiling out runtime platform checks is probably not worth the potential instability.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-17T07:40:35.000+0000", "updated": "2012-09-17T07:40:35.000+0000" }, { "id": "219246", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The initial developer reported issue has been resolved by disabling the optimizer. ALOY-274 has been created to discuss how we can potentially re-enable the optimizer.js code, and if this is even desired.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-17T08:20:30.000+0000", "updated": "2012-09-17T08:20:30.000+0000" }, { "id": "225254", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "This is not fixed and must be reopened and fixed", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-10-27T07:18:59.000+0000", "updated": "2012-10-27T07:18:59.000+0000" }, { "id": "225258", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I was using ALOY-274 as a broad stroke to cover tightening up the optimizer.js code, which included this issue. I'll reopen this one and make it a dependency of it.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-27T21:45:24.000+0000", "updated": "2012-10-27T21:45:24.000+0000" }, { "id": "227485", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "optimizer.js code now handles conditionals with no curly braces. All tests pass, including new ones that test this use case. This is all a result of a major simplification of the optimizer.js code in combination with allowing uglifyjs to remove dead code based on string to string comparisons. In the end we have a more stable optimizer that covers more cases and handles all known edge cases. The commit(s) can be seen here:\r\n\r\n* refactored code:\r\n** https://github.com/appcelerator/alloy/commit/bcaffef93fada754103f4e1b8927133bb41f250a\r\n** https://github.com/appcelerator/alloy/commit/a2e3294d6ab695b9a2f44d229f969a7fd9933453", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-15T16:09:28.000+0000", "updated": "2012-11-15T16:09:28.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }