Problems with strict-mode caller poisoning

Andreas Rossberg rossberg at google.com
Wed Nov 28 15:43:38 PST 2012


On 29 November 2012 00:16, Dave Fugate <dave.fugate at gmail.com> wrote:
> Believe you're correct on the former, but perhaps not the latter=)
>
> E.g.:
>      6 /**
>      7    * @path ch15/15.3/15.3.5/15.3.5.4/15.3.5.4_2-1gs.js
>      8    * @description Strict mode - checking access to strict function
> caller from strict function (FunctionDeclaration defined within strict mode)
>      9   * @onlyStrict
>     10  * @negative TypeError
>     11  */
>     12
>     13
>     14 "use strict";
>     15 function f() {
>     16     return gNonStrict();
>     17 }
>     18 f();
>     19
>     20
>     21 function gNonStrict() {
>     22     return gNonStrict.caller;
>     23 }
>
> is globally scoped strict mode and passes only when a TypeError gets thrown
> indicating strict mode is in effect.

The bug with this test (and others) is that gNonStrict is _not_ a
non-strict function, its name notwithstanding. Hence the test throws
for the wrong reason, namely because strict-function.caller is a
poisoned getter, not because of Sec 15.3.5.4, which it is supposed to
test.

/Andreas


More information about the es-discuss mailing list