Typically, arrays in javascript are extensible, but this is not true for the array passed as the first argument of a tag function:
let ary = [1,2,3];
console.log(Object.isExtensible(ary));
// returns true
function tag(ary, ...expressionResults)
{
console.log(Array.isArray(ary));
//returns true
console.log(Object.isExtensible(ary));
// returns false
}
tag`test`;
Where, exactly, in the specification, is this array deemed non-extensible? I'm not even sure if I'm looking at the right spot.
You were looking in the right spot. The linked spec even offers a note as to why (emp. mine):
If you want to understand the actual execution, first look at the tagged templates' runtime semantics are specified in Section 12.3.7.1:
If you take a look at abstract operation EvaluateCall:
So, when calling a tag function with a template literal, the ArgumentListEvaluation of the TemplateLiteral is passed as the argument to the tag function. Taking a look at ArgumentListEvaluation:
Looking at operation GetTemplateObject, we see the culprit:
Where template is array passed to the tag function. We see that it's explicitly frozen. If you want to go a level deeper, see SetIntegrityLevel:
And taking a look at [[PreventExtensions]] of an ordinary object, we see that operation OrdinaryPreventExtensions is called:
So the [[Extensible]] internal slot is explicitly set to false.