mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
[INFER] Always add type for 'arguments' variables, even with local redefinitions, bug 621126.
This commit is contained in:
parent
01a2274ce4
commit
45c4e52a1d
35
js/src/jit-test/tests/basic/builtinLocals.js
Normal file
35
js/src/jit-test/tests/basic/builtinLocals.js
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
/* Resolve 'arguments' and the name of the function itself in the presence of such local variables. */
|
||||
|
||||
function f() {
|
||||
return typeof arguments;
|
||||
function arguments() {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
assertEq(f(), "object");
|
||||
|
||||
function g() {
|
||||
var arguments = 0;
|
||||
return typeof arguments;
|
||||
}
|
||||
assertEq(g(), "number");
|
||||
|
||||
function h() {
|
||||
return typeof h;
|
||||
function h() {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
assertEq(h(), "function");
|
||||
|
||||
function i() {
|
||||
return typeof i;
|
||||
var i;
|
||||
}
|
||||
assertEq(i(), "undefined");
|
||||
|
||||
function j() {
|
||||
return typeof j;
|
||||
}
|
||||
assertEq(j(), "function");
|
@ -1872,9 +1872,17 @@ Script::addVariable(JSContext *cx, jsid id, types::Variable *&var, bool localNam
|
||||
JS_ASSERT(!var);
|
||||
var = ArenaNew<types::Variable>(pool, &pool, id);
|
||||
|
||||
/* Variables which are definitely arguments or locals do not pull in builtin types. */
|
||||
if (!localName) {
|
||||
/* Augment with types for the 'arguments' variable. */
|
||||
/*
|
||||
* Augment with types for the function itself, unless this is an argument or
|
||||
* local variable of the function.
|
||||
*/
|
||||
if (!localName && fun && id == ATOM_TO_JSID(fun->atom))
|
||||
var->types.addType(cx, (jstype) function());
|
||||
|
||||
/*
|
||||
* Augment with types for the 'arguments' variable, even if there is a local
|
||||
* variable named 'arguments'
|
||||
*/
|
||||
if (fun && id == id_arguments(cx)) {
|
||||
if (script->compileAndGo)
|
||||
var->types.addType(cx, (jstype) getTypeNewObject(cx, JSProto_Object));
|
||||
@ -1882,11 +1890,6 @@ Script::addVariable(JSContext *cx, jsid id, types::Variable *&var, bool localNam
|
||||
var->types.addType(cx, TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
/* Augment with types for the function itself. */
|
||||
if (fun && id == ATOM_TO_JSID(fun->atom))
|
||||
var->types.addType(cx, (jstype) function());
|
||||
}
|
||||
|
||||
InferSpew(ISpewOps, "addVariable: #%lu %s T%u",
|
||||
this->id, TypeIdString(id), var->types.id());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user