Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 16, 2026

Ref #391

The first commit:

  • adds support for structured headers in abstract method declarations. A list of abstract method declarations is introduced by <emu-table type="abstract methods">.
  • adds abstract methods as ops to the biblio, so that autolinking will find their references and auto-link to the declaration

The second commit:

  • adds concrete methods to the biblio
  • introduces an <emu-concrete-method-dfns for="SomeAbstractMethodName">, which auto-expands to a list of definitions for SomeAbstractMethodName

With both together, this code:

  <emu-table type="abstract methods" of="Module Record" id="table-abstract-methods-of-module-records">
    <table>
      <thead>
        <tr>
          <th>Method</th>
          <th>Description</th>
          <th>Definitions</th>
        </tr>
      </thead>
      <tr>
        <td>
          ResolveExport (
            _exportName_: a String,
            <ins>_resolveSet_: a List of Module Records,</ins>
          ): either a Module Record or *null*
        </td>
        <td>It does something when called.</td>
        <td>
          It is defined in the following places:
          <emu-concrete-method-dfns for="ResolveExport"></emu-concrete-method-dfns>
        </td>
      </tr>
    </table>
  </emu-table>

Is rendered like this:

image

This PR does not introduce yet any checks that the signatures match.

Some questions:

  1. Right now the links from usage sides to abstract method definitions just link to the table, should they have more precise links?
  2. Usually AO signatures are wrapped in <h1>, but I'm not sure it makes much sense to do it inside a table. Should I do it anyway for consistency?

@bakkot
Copy link
Member

bakkot commented Jan 16, 2026

This looks great, thank you!

Can you also add a test which confirms that we now get signature-based errors for invocations of abstract methods? E.g. that if we have an abstract method Method with signature ( _x_: a string ), then invoking it as _foo_.Method(~enum~) and _foo_.Method(*"string"*, *"extra"*) both give warnings.

const li = spec.doc.createElement('li');
const xrefNode = spec.doc.createElement('emu-xref');
xrefNode.setAttribute('href', `#${def.refId}`);
xrefNode.textContent = def.for;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we prefix it with the section number?

Copy link
Member

@bakkot bakkot Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be possible to get that for free by re-using the existing emu-xref machinery by simply not populating textContent here. Alternatively, if that doesn't work because that phase has already run or something, we can export and re-use the relevant function directly.

Copy link
Member Author

@nicolo-ribaudo nicolo-ribaudo Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not putting the text content seems to give just the number, without the text. I'll do it manually.

Would we want the number of the section (e.g. 16.2.1.2 Source Text Module Record) or of the specific concrete method that we are linking to (e.g. 16.2.1.7.2.2 Source Text Module Record)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going ahead with the full number, since that seems to be more useful when manually looking for the number (e.g. in a printed version), even if the title doesn't match.

@nicolo-ribaudo
Copy link
Member Author

invoking it as _foo_.Method(~enum~)

Is this meant to warn because of the mismatched argument type? I do not seem to be getting that warning even with plain AOs.

@bakkot
Copy link
Member

bakkot commented Jan 16, 2026

Is this meant to warn because of the mismatched argument type? I do not seem to be getting that warning even with plain AOs.

Sorry, has to be spelled "a String", with the capital letter, to actually work. Full example:

<pre class="metadata">
copyright: false
</pre>
<emu-clause id="example" type="abstract operation">
  <h1>
    Example (
      arg: a String,
    ): ~unused~
  </h1>
  <dl class="header"></dl>
</emu-clause>
<emu-alg>
  1. Perform Example(~enum~).
</emu-alg>
$ ./bin/ecmarkup.js --lint-spec test.emu /dev/null
Warning: inlining assets; this should not be done for production builds.
[2026-01-16T21:03:31.921Z] Warning: test.emu:13:22: argument (~enum~) does not look plausibly assignable to parameter type (String)

@nicolo-ribaudo
Copy link
Member Author

Oh yes that worked, thanks.

Copy link
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@bakkot
Copy link
Member

bakkot commented Jan 16, 2026

Looks great but should also get docs (under spec/index.html). I would do it as a subsection of emu-table I guess. I can do that myself in the next couple days if you don't get around to it before then.

@bakkot
Copy link
Member

bakkot commented Jan 19, 2026

Updated docs but I want to make another couple tweaks first (making for parsing only apply to concrete methods; adding a lint to enforce that the concrete and abstract match).

This PR will be a breaking change (because it enforces that _foo_.Bar() has a corresponding abstract method definition Bar, using the new element), so also I want to hold off on landing it until I get the 262 PR ready as well.

@bakkot
Copy link
Member

bakkot commented Jan 20, 2026

OK, I'm happy with this, and got ecma262 building: tc39/ecma262#3745

@bakkot bakkot merged commit 2720d8e into tc39:main Jan 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants