Hi all!
I need some clarification around completion records.
Let me start with examples in the spec (7.0) and explain how I
understand them (and what I don't understand):
```
12.1.6 Runtime Semantics: Evaluation
IdentifierReference: Identifier
Return ?ResolveBinding(StringValue of Identifier).
```
`ResolveBinding` is an abstract operation which can return a completion
record, but in the successful case, it returns a Reference (spec type)
not a completion record. Either way, since the "IdentifierReference
evaluation" algorithm is not an abstract operation, the Reference is
returned, not a completion record. (Note 1 also says "The result of
evaluating an IdentifierReference is always a value of type Reference.")
Now when I look at
```
13.5.1 Runtime Semantics: Evaluation
ExpressionStatement: Expression;
1. Let exprRef be the result of evaluating Expression.
2. Return ?GetValue(exprRef).
```
it seems to support my interpretation (`exprRef` must be a reference in
a successful case) and I would assume that "evaluating an
ExpressionStatement" also returns whatever `?GetValue(exprRef)` returns,
*not* a completion record.
But when then look at
```
13.2.13 Runtime Semantics: Evaluation (Block)
StatementList: StatementList StatementListItem
1. Let sl be the result of evaluating StatementList.
2. ReturnIfAbrupt(sl).
3. Let s be the result of evaluating StatementListItem.
4. Return Completion(UpdateEmpty(s, sl)).
```
It seems that "evaluating StatementListItem" *must* result in a
completion record, which seems to contradict my understanding of
"evaluating" something.
---
The only other explanation seems to be that "the result of evaluating
Expression" is a completion record and `exprRef` is the implicitly
unwrapped value according to 6.2.2.2:
> Any reference to a Completion Record value that is in a context that
> does not explicitly require a complete Completion Record value is
> equivalent to an explicit reference to the [[Value]] field of the
> Completion Record value unless the Completion Record is an abrupt
> completion.
Which would mean that "evaluating an IdentifierReference" actually
returns a completion record whose value is a Reference (spec type)?
And would that mean that evaluating "ExpressionStatement: Expression;"
is actually performing:
```
2. let value be ?GetValue(exprRef).
3. return NormalCompletion(value).
```
---
Related: Is any *language type* always returned/passed via a normal
completion record? My understanding is that an operation might not
return a completion record if the return value is a specification type.
But is it always a completion record if the value is a language type?
I hope at lest part of what I said is correct, thank you in advance for
your help!
Felix