Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

96 lines
2.8 KiB
Plaintext

== Why is this an issue?
``++eval++`` is used to evaluate a string as JavaScript code, and ``++arguments++`` is used to access function arguments through indexed properties. As a consequence, ``++eval++`` and ``++arguments++`` should not be bound or assigned, because doing so would overwrite the original definitions of those two reserved words.
What's more, using either of those two names to assign or bind will generate an error in JavaScript strict mode code.
=== Noncompliant code example
[source,javascript]
----
eval = 17; // Noncompliant
arguments++; // Noncompliant
++eval; // Noncompliant
var obj = { set p(arguments) { } }; // Noncompliant
var eval; // Noncompliant
try { } catch (arguments) { } // Noncompliant
function x(eval) { } // Noncompliant
function arguments() { } // Noncompliant
var y = function eval() { }; // Noncompliant
var f = new Function("arguments", "return 17;"); // Noncompliant
function fun() {
if (arguments.length == 0) { // Compliant
// do something
}
}
----
=== Compliant solution
[source,javascript]
----
result = 17;
args++;
++result;
var obj = { set p(arg) { } };
var result;
try { } catch (args) { }
function x(arg) { }
function args() { }
var y = function fun() { };
var f = new Function("args", "return 17;");
function fun() {
if (arguments.length == 0) {
// do something
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the modification of "xxx".
Do not use "xxx" to declare a [variable|parameter|class|function] - use another name.
=== Highlighting
declaration or assignment of special word
'''
== Comments And Links
(visible only on this page)
=== on 8 Apr 2015, 09:28:51 Elena Vilchik wrote:
\[~ann.campbell.2] I fixed description a little bit. Could you validate that?
=== on 8 Apr 2015, 18:32:12 Ann Campbell wrote:
\[~elena.vilchik] w3schools.com lists both of those as reserved words. That makes me wonder why we have a rule that covers only those 2 reserved words and not all of them...?
=== on 9 Apr 2015, 07:12:59 Elena Vilchik wrote:
\[~ann.campbell.2] I'm not sure, may be [~linda.martin] has more information. I've found this info \https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-static-semantics-early-errors
=== on 9 Apr 2015, 11:43:40 Ann Campbell wrote:
I'm assigning this to [~linda.martin] so she can weigh-in on the discussion
=== on 19 May 2015, 15:49:16 Linda Martin wrote:
Sorry for the late reply. "arguments" and "eval" are not reserved word it is a syntax error (in normal mode) to assign or defined a variable with a reserved word as the identifier. So IMHO it would not make sens to check for reserved words.
=== on 19 May 2015, 19:11:13 Ann Campbell wrote:
okay, I think we're good then [~elena.vilchik] (cc [~linda.martin])
endif::env-github,rspecator-view[]