Ecma262: Editorial Clarification: Contains definition in 5.2.4 may be misleading

Created on 11 Dec 2020  路  3Comments  路  Source: tc39/ecma262

I don't know if I am the only person who will be confused with this, but worth asking. When preparing to introduce top level await on the stream, I came across the following line:

Let async be body Contains await. -- Knowing what top level await does, obviously, this must be ignoring functions right?

I double checked in the spec. The first definition, when looking it up in the spec is this one here: https://www.ecma-international.org/ecma-262/11.0/index.html#sec-static-semantic-rules

    For each child node child of this Parse Node, do
        If child is an instance of symbol, return true.
        If child is an instance of a nonterminal, then
            Let contained be the result of child Contains symbol.
            If contained is true, return true.
    Return false.

This is a bit misleading, as later on we have notes like this one:

https://www.ecma-international.org/ecma-262/11.0/index.html#sec-object-initializer-static-semantics-contains

Static semantic rules that depend upon substructure generally do not look into function definitions.

That seems pretty important. Maybe we should add this note to the description of the algorithm above?

Most helpful comment

Hm. The text surrounding the algorithm steps you quote is pretty explicit about the fact that the given definition is overridden for some productions, to my eyes. Is the ask that it be clearer about which ones, or am I misunderstanding?

Either way, I'll be sure to revise this as part of https://github.com/tc39/ecma262/issues/1950, which will hopefully make this totally clear by putting the whole definition in a single place.

All 3 comments

Hm. The text surrounding the algorithm steps you quote is pretty explicit about the fact that the given definition is overridden for some productions, to my eyes. Is the ask that it be clearer about which ones, or am I misunderstanding?

Either way, I'll be sure to revise this as part of https://github.com/tc39/ecma262/issues/1950, which will hopefully make this totally clear by putting the whole definition in a single place.

I agree with @bakkot, I don't think this would've been a problem if you could see the definition of Contains all in one place.

That sounds like a much more comprehensive change, and I would be in favor of that!

Was this page helpful?
0 / 5 - 0 ratings