Skip to content

Early throw on generator not catched #10365

Closed
@magic-akari

Description

@magic-akari

Describe the bug

Test case from https://github.com/tc39/test262/blob/afc3d1bce4ae643e74296fb21d8665ec43a1f2bd/test/built-ins/AsyncGeneratorPrototype/throw/return-rejected-promise.js

Input code

async function* g() {}

var errormessage = "Promise rejected."
var result = g().throw(new Test262Error(errormessage))

assert(result instanceof Promise, "Expected result to be an instanceof Promise")

result.then(
  function () {
    throw new Test262Error("Expected result to be rejected promise.");
  },
  function (e) {
    if (!(e.message = errormessage)) {
      throw new Test262Error("Expected thrown custom error, got " + e);
    }
  }
).then($DONE, $DONE)

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "target": "es5",
    "loose": false,
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true,
}

Link to the code that reproduces this issue

swc playground

SWC Info output

No response

Expected behavior

Test262:AsyncTestComplete

Actual behavior

Test262:AsyncTestFailure:Test262Error: Test262Error: Expected result to be rejected promise.

Version

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions