MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix the strict/non-simple-params regression from 484170ac

+18 -5
+8 -5
src/silver/compiler.c
··· 4243 4243 4244 4244 comp.param_locals = comp.local_count; 4245 4245 4246 - if (!comp.is_strict && node->body && node->body->type == N_BLOCK) { 4247 - for (int i = 0; i < node->body->args.count; i++) { 4246 + bool has_own_use_strict = false; 4247 + if (node->body && node->body->type == N_BLOCK) for (int i = 0; i < node->body->args.count; i++) { 4248 4248 sv_ast_t *stmt = node->body->args.items[i]; 4249 4249 if (!stmt || stmt->type == N_EMPTY) continue; 4250 4250 if (stmt->type != N_STRING) break; 4251 - if (sv_ast_is_use_strict(comp.js, stmt)) comp.is_strict = true; 4252 - }} 4251 + if (sv_ast_is_use_strict(comp.js, stmt)) { 4252 + has_own_use_strict = true; 4253 + comp.is_strict = true; 4254 + } 4255 + } 4253 4256 4254 4257 if (comp.is_strict) { 4255 4258 const char *param_names[256]; ··· 4304 4307 if (p->type != N_IDENT) { has_non_simple_params = true; break; } 4305 4308 } 4306 4309 4307 - if (comp.is_strict && has_non_simple_params) { 4310 + if (has_own_use_strict && has_non_simple_params) { 4308 4311 js_mkerr_typed( 4309 4312 comp.js, JS_ERR_SYNTAX, 4310 4313 "Illegal 'use strict' directive in function with non-simple parameter list");
+10
tests/test_es2016_includes_and_strict.cjs
··· 73 73 } 74 74 assert.strictEqual(threw, true); 75 75 76 + assert.doesNotThrow(() => { 77 + const fn = Function('"use strict"; return function(a = 1) { return a; };')(); 78 + assert.strictEqual(fn(), 1); 79 + }); 80 + 81 + assert.doesNotThrow(() => { 82 + const fn = Function('"use strict"; return function(...a) { return a.length; };')(); 83 + assert.strictEqual(fn(1, 2), 2); 84 + }); 85 + 76 86 console.log("ES2016 includes and strict-mode regressions pass");