tc39 / tc39/ecmarkup

False positive warning about "returning an abrupt completion"

Open
#619 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
245
Forks
80
Avg merge
10h 46m
Merged PRs (30d)
2

Description

it warns for the following code after upgrading from 19.1.0 to 20.0.0. It uses ReturnIfAbrupt.

Warning: spec.emu: this algorithm is declared as returning an abrupt completion, but there is no step which might plausibly return an abrupt completion

<emu-clause id="sec-iterator-step-cached" type="abstract operation">
    <h1>
    IteratorStepCached (
        _iterator_: an Iterator Record,
        _cacheGroup_: a %Map%,
    ): either a normal completion containing either an ECMAScript language value or ~not-matched~, or an abrupt completion
    </h1>
    <dl class="header">
    </dl>
    <emu-alg>
    1. Assert: _cacheGroup_ is created by CreateMatchCache and used internally for pattern-matching.
    1. If _iterator_.[[Done]] is *true*, return ~not-matched~.
    1. Let _cache_ be GetMatchCache(_iterator_, _cacheGroup_).
    1. Let _iteratedValues_ be ! Get(_cache_, *"IteratedValues"*).
    1. Let _iteratorResult_ be Completion(IteratorStep(_iterator_)).
    1. If _iteratorResult_ is an abrupt completion, set _iterator_.[[Done]] to *true*.
    1. ReturnIfAbrupt(_iteratorResult_).
    1. If _iteratorResult_ is *false*, then
        1. Set _iterator_.[[Done]] to *true*.
        1. Return ~not-matched~.
    1. Let _value_ be Completion(IteratorValue(_iteratorResult_)).
    1. If _value_ is an abrupt completion, set _iterator_.[[Done]] to *true*.
    1. ReturnIfAbrupt(_value_).
    1. Perform ! Call(<emu-xref href="#sec-array.prototype.push">%Array.prototype.push%</emu-xref>, _iteratedValues_, « _value_ »).
    1. Return _value_.
    </emu-alg>
</emu-clause>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning with the IteratorStepCached emu-clause shown in the issue, using ecmarkup 20.0.0 after comparing with 19.1.0. Trace the validation that reports an algorithm as lacking a plausible abrupt completion. Done means this example no longer produces the false-positive warning while genuine cases still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.