espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.78k stars 746 forks source link

Functions with default parameters are not properly supported #2257

Closed Swordstone86 closed 2 years ago

Swordstone86 commented 2 years ago

Functions with default parameters seem to be throwing SyntaxErrors.

Firmware version: 2v15 Web IDE version: v0.76.1

Input code:

function test(a = 3, b = 4, c = 5) {
  print(a);
}

Error:

Uncaught SyntaxError: Got '=' expected ','
 at line 1 col 17 in .bootcde
function test(a = 3, b = 4, c = 5) {
                ^

Expected result is the function behaves normally with default parameters, and can be called any of the following ways:

test();
test(11);
test(44, 23);
gfwilliams commented 2 years ago

Hi - Espruino doesn't support all of ES6 - there's a list of features to does/doesn't support here: http://www.espruino.com/Features

I'm going to close this as otherwise we'll just end up with hundreds of bugs for every feature in every ES version that's not implemented - there's already a feature wishlist at https://github.com/espruino/Espruino/issues/1302 where this is listed.