Titanium JIRA Archive
Alloy (ALOY)

[ALOY-907] JavaScript syntax error output is incorrect and confusing

GitHub Issuen/a
Resolution Date2013-12-20T20:27:10.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.4.0, Alloy 1.3.1, 2013 Sprint 26
ReporterChris Barber
AssigneeTony Lukasavage


When building an Alloy app with the following in the index.js controller:
function doClick(e) {

Alloy outputs the following error:
[WARN]  : ERROR: Unexpected token: punc ({) [null:5,14]
[DEBUG] C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:199
[ERROR] (message, line, col, pos);
[DEBUG]           ^
[ERROR] (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:185:18)
[ERROR] (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:199:11)
[DEBUG]     at croak (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:630:9)
[ERROR] (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:638:9)
[DEBUG]     at unexpected (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:644:9)
[DEBUG]     at semicolon (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:664:43)
[DEBUG]     at simple_statement (C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:822:73)
[DEBUG]     at C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:707:19
[DEBUG]     at C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:677:24
[DEBUG]     at C:\Users\Thomas Anderson\AppData\Roaming\npm\node_modules\alloy\node_modules\uglify-js\lib\parse.js:1395:23
[ERROR] Alloy compiler failed
There are multiple problems with this output: 1) The error is printed as a warning 2) Nowhere does it indicate the actual filename containing the error 3) It displays the entire stack trace of the Alloy code which is irrelevant to the user's app To resolve this, Alloy should: 1) Show the output as an error, not a warning 2) Show the filename in which the error is found 3) Do not show the stack trace 4) The error should be displayed similar to the Titanium CLI which would look like:
[ERROR] Failed to minify C:\Users\Thomas Anderson\Documents\Appcelerator_Studio_Workspace\testapp\app\controllers\index.js
[ERROR] Unexpected token: punc ({) [line 5, column 14]
[ERROR]     $.index.open(){};
[ERROR]     --------------^


  1. Tony Lukasavage 2013-12-20

    commit: https://github.com/appcelerator/alloy/commit/063cd1b6c597044a81314582548a0c5472d22255 Merged in both master and 1_3_X

    functional test

    Use the test app from the description

    Compile alloy: alloy compile --platform ios

    Assert that you now get a specific error with the stack trace suppressed, looking something like this:

       [ERROR] Error generating AST for "/Users/tlukasavage/Development/backwards/app/controllers/index.js"
       [ERROR] Unexpected token: punc ({)
       [ERROR] line 5, column 14, position 64
  2. Olga Romero 2014-01-08

    Tested the app from description.

    Actual result

       [WARN] :   : ERROR: Unexpected token: punc ({) [null:5,14]
       [ERROR] :  Error generating AST for "/Users/oromero/Documents/Appcelerator_Studio_Workspace2/before/app/controllers/index.js"
       [ERROR] :  Unexpected token: punc ({)
       [ERROR] :  line 5, column 14, position 64
       [ERROR] :  Alloy compiler failed
    Environment: Mac osx 10.9.1 Appcelerator Studio, build: Titanium SDK, build: 3.2.1.v20140106195644 Titanium SDK, build: 3.3.0.v20140106195650 Node.JS Version: v0.10.13 NPM Version: 1.3.2 ├── acs@1.0.11 ├── alloy@1.3.1-beta ├── npm@1.3.2 ├── titanium@3.2.0 └── titanium-code-processor@1.1.0 └── titanium@3.2.0

JSON Source