diff --git a/src/duk_features.h.in b/src/duk_features.h.in index 2c744ebc..88b39f97 100644 --- a/src/duk_features.h.in +++ b/src/duk_features.h.in @@ -2260,6 +2260,11 @@ typedef FILE duk_file; #define DUK_USE_MATH_BUILTIN #endif +#define DUK_USE_STRICT_DECL +#if defined(DUK_OPT_NO_STRICT_DECL) +#undef DUK_USE_STRICT_DECL +#endif + #define DUK_USE_REGEXP_SUPPORT #if defined(DUK_OPT_NO_REGEXP_SUPPORT) #undef DUK_USE_REGEXP_SUPPORT diff --git a/src/duk_js_compiler.c b/src/duk_js_compiler.c index 01c0f7f2..30c328b6 100644 --- a/src/duk_js_compiler.c +++ b/src/duk_js_compiler.c @@ -6172,18 +6172,20 @@ DUK_LOCAL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_ DUK_DDD(DUK_DDDPRINT("directive contains escapes: valid directive " "but we ignore such directives")); } else { - /* XXX: how to compare 'use strict' most compactly? - * We don't necessarily want to add it to the built-ins - * because it's not needed at run time. + /* * The length comparisons are present to handle * strings like "use strict\u0000foo" as required. */ if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 && DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) { +#if defined(DUK_USE_STRICT_DECL) DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld", (long) comp_ctx->curr_func.is_strict, (long) 1)); comp_ctx->curr_func.is_strict = 1; +#else + DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring")); +#endif } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 && DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) { DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld",