gkz / LiveScript

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming.
http://livescript.net
MIT License
2.31k stars 156 forks source link

Throw syntax error on a function call line which ends with a comma and further line(s) without indentation #1108

Open ceremcem opened 3 years ago

ceremcem commented 3 years ago

I've came across with this case numerous times. Consider the following example:

hello foo, bar
hi there

Compiled output is obviously:

hello(foo, bar);
hi(there);

Then I remove the bar parameter, but accidentally forgot to remove the comma. The compiled output becomes:

hello(foo, hi(there));

instead of:

hello(foo);
hi(there);

Proposal

I guess this is not a bug, but a feature. However, I think LiveScript will be more error resistant if this feature is removed and users are forced to use backslash or parenthesis for multi line splitting purposes.

At least, an indentation for further lines must be required for considering a line to be split. to consider the line split.

vendethiel commented 3 years ago

warning when there's no indentation sounds OK, but that's definitely a feature.

determin1st commented 3 years ago

what will happen with:

callFunc param,
         anotherParam,
         someFlag

beauty will suffer :(

ceremcem commented 3 years ago
callFunc param,
         anotherParam,
         someFlag

is okay, however the following - which is my vote - will throw syntax error:

callFunc param,
anotherParam,
someFlag

Second one is also confusing to human eye anyway.