misleading strict warning: function eval must be called directly, and not by way of a function of another name.

RESOLVED INVALID

Status

()

RESOLVED INVALID
15 years ago
14 years ago

People

(Reporter: timeless, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
test case:
js> foo={'eval':eval}
[object Object]
js> foo.eval("1")
typein:6: strict warning: function eval must be called directly, and not by way 
of a function of another name.
1

the real world example i have involves two dom windows.
i need to eval my string (a function that references |window| coerced to a 
string) in the context of the 'other' dom window, because i need (that 
function's) |window| to reference that other window, not the one that's global 
to the js i'm executing.

since i'm calling some_global_window.eval, i don't think i'm calling a function 
by another name. If the strict warning does not want me to call it via an 
object property of any name, then it should say so :(.

and if that's the case, then i have to ask, how does one evaluate code in the 
context of a different dom window?

am i supposed to do:
some_global_window.setTimeout('eval(...)') ?

Comment 1

14 years ago
If I understand it correctly, the warning is due to the clause in 15.1.2.1 
eval(x) <quote>If value of the eval property is used in any way other than a
direct call (that is, other than by the explicit use of its name as an
Identifier which is the MemberExpression in a CallExpression), or if the eval
property is assigned to, an EvalError  exception may be thrown.</quote> We don't
do the EvalError, but instead issue a warning.

The win.setTimeout will work, but you don't need the eval or you can use the
deprecated with (win} { do stuff }.

-> invalid, reopen if you disagree.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
QA Contact: pschwartau → moz
Resolution: --- → INVALID
(Reporter)

Comment 2

14 years ago
i've never had with (foo) work, it looks like eval(string, obj) might do what i
want when it doesn't crash.
You need to log in before you can comment on or make changes to this bug.