- Spread keeps its list of elements counted against the heap limit until
the elements are the array's properties, so a list and an array that
only fit one at a time end the run with the heap limit.
- A script stopped at the fuel or heap limit while its functions and
variables are declared removes its `let` and `const` names from the
global scope, so running it again in the same realm does not throw a
redeclaration error. A script that throws once it runs keeps them.
- A function whose only non-simple parameter is a rest parameter keeps
its parameters and body in one environment (ECMA-262 2015 section
9.2.12), so `var r` in the body or in direct eval is the parameter.
Its `arguments` object still does not follow the parameters.
A function declaration standing alone as an if branch outside strict
mode code is in a block of its own (Annex B.3.4), so a function of the
same name in the block around the if keeps it from assigning the outer
variable: var f; { function f() { return 1; } if (true) function f()
{ return 2; } } f() gives 1.
Global and eval code stays in the collector's roots while its
declarations are made, so a collection in that time keeps the code's
heap charge.
- Direct eval in a derived constructor, or in an arrow function inside
one, reads the constructor's this binding when it runs, so
eval('this') before super() throws a ReferenceError, and an arrow
function made by the eval code sees this once super() returns.
- A class's heritage and computed keys run as strict mode code inside
sloppy code; the code after the class, and a handler of what they
throw, stay sloppy.
- A super property write that cannot be made throws with
Realm::set_strict_writes, as other property writes do.
- A labeled function in a block is made when the block is entered and
declares its name in the block, so { let f; L: function f() {} } is
a SyntaxError. A block function whose name a function of an
enclosing block also declares no longer assigns the outer variable.
- Methods reject duplicate parameter names outside strict mode code.
- With a global object that is not extensible, a var that would add a
property throws a TypeError before the script or the eval code
declares anything.
- The receiver, arguments and new.target of a call, a strict eval's
own environment and spread's elements stay reachable while their
scopes and properties are made, and spread counts the array's new
properties against the heap limit before it adds them.
- Tagged template strings objects are dropped once nothing but the
cache holds their code, also for code with several sites.
- A //@ or # directive after a template with a substitution that
spans lines is read only at the start of a line.
- The code size estimate counts a block scope's entries by their size.
A class can name any constructor in extends. The docs said extending a
built-in other than Object, Function, Array, String, Number, Boolean,
RegExp, Date and the error types throws; the TypeError comes when new
on the class reaches the built-in constructor. The docs now say so, a
test covers the rule, and the Options::es2015 doc lists classes and
object literal methods.
With Options::es2015, vectorcraft-js reads and runs ECMAScript 2015
classes: declarations, scoped to their block like let, and
expressions, with extends, static members, getters and setters and
computed method names. Class code is strict mode code, methods are
not enumerable and cannot be constructed, and calling a class without
new throws a TypeError.
A derived constructor's this throws a ReferenceError until super(...)
returns, and its default constructor passes its arguments on.
super.name and super[key] read, call and write through the prototype
of the method's home object, in class methods and in object literal
methods, which ES2015 allows in a .js script. new.target names the
constructor new was applied to, in functions and their arrow
functions. A class can extend null, a function, a class, or the
built-in constructors Object, Function, Array, String, Number,
Boolean, RegExp, Date and the error types; extending any other
built-in throws a TypeError. Each class and method takes fuel and
counts against the heap limit, and deep constructor chains stop at
the frame limit. A .jsx file and a source string stay ES5.1, where
class syntax is a SyntaxError.
The test262 runner adds the class, super and new.target tests to its
ES2015 subset (1,125 tests). With the option, 554 of 554 negative
parse runs and 1,527 of 1,633 other runs pass; the failing runs use
Object.setPrototypeOf, RegExp.prototype.flags, function name
properties, a configurable length, the caller and arguments
restrictions, or super and new.target in direct eval.
Docs: docs/mcp.md, docs/target-app-parity.md.
With ES2015 scripts, a function declaration was judged by a property the
global object inherits, so a fixed property on Object.prototype stopped
`function name() {}`. The check now reads the global object's own
property, as ECMA-262 2015 section 8.1.1.4.16 does, and declares nothing
when the global object is not extensible and has no property of that
name. Indirect eval code makes the same check for all of its functions
before it declares any of them, and a function declaration never adds a
property to a global object that is not extensible.
A call to a function with a rest parameter built the array of its extra
arguments without reserving room for it, so `f.apply(null, big)` could
push the heap estimate past the limit. The call now counts the rest
array, its binding and one property per extra argument in the room it
reserves before the function's environment is made.
Spreading a concatenated string (`[...s]`, `f(...s)`) flattened it before
any limit was checked, so a script could make the host build the whole
copy before the per-element fuel and heap accounting ran. The spread now
flattens through the same counted helper the string built-ins use, which
ends the run with the heap limit before the copy is made.
A function declared in a block sets the enclosing variable of its name
only when that declaration itself is eligible, so a declaration inside
a let of the same name no longer assigns the variable because another
declaration of that name elsewhere in the body is eligible.
Spread of an object with a length property reads the length with
ToLength, so a negative or NaN length adds no elements instead of
wrapping to a count near 2^32. A function body's environments stay on
the collector's roots while its scope, functions and arguments object
are made.
Global code runs in the realm's lexical scope in either language, so a
function an earlier ES5.1 run, an indirect eval or the Function
constructor made can read a let or const a later .js run declares. With
the ES2015 option, a script whose function cannot replace a property of
the global object throws a TypeError before any of its let or const
names is declared, so a failed run leaves no name uninitialized.
vectorcraft-js gains Options::es2015, which reads and runs these
ECMAScript 2015 forms: let and const with block scope and their
temporal dead zone, a new let binding for each loop iteration,
function declarations scoped to their block (with the Annex B.3.3
variable outside strict mode code), arrow functions, template
literals and tagged templates, default and rest parameters, and
spread in array literals, calls and new. Spread reads arrays,
strings by code point and objects with a length, by index, and
throws a TypeError for anything else until iterators are added.
Eval code outside strict mode code cannot declare a var that clashes
with a let or const around it, or with a parameter inside a default
value. Spread, template objects and the new scopes take fuel and
count against the heap limit, and nested arrows and templates count
against the depth limit.
script.run sets the option for a .js file; eval, Function, #include
files, $.evalFile and a kept #targetengine read code the way the
running script does. A .jsx file and a source string stay ES5.1.
The test262 runner gains an ES2015 subset run, read without and with
the option. docs/mcp.md and docs/target-app-parity.md describe the
new forms.