[ALOY-907] JavaScript syntax error output is incorrect and confusing
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-12-20T20:27:10.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.4.0, Alloy 1.3.1, 2013 Sprint 26 |
Components | n/a |
Labels | n/a |
Reporter | Chris Barber |
Assignee | Tony Lukasavage |
Created | 2013-12-20T19:14:46.000+0000 |
Updated | 2014-02-05T17:53:34.000+0000 |
Description
When building an Alloy app with the following in the index.js controller:
function doClick(e) {
alert($.label.text);
}
$.index.open(){};
Alloy outputs the following error:
[WARN] : ERROR: Unexpected token: punc ({) [null:5,14]
[DEBUG]
[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]
[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]
[ERROR] $.index.open(){};
[ERROR] --------------^
[ERROR]
Comments
- 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
- Olga Romero 2014-01-08
Tested the app from description.
Actual result
Environment: Mac osx 10.9.1 Appcelerator Studio, build: 3.2.1.201401071645 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[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