Skip to content

Importing files suppress async generators are unsupported errors #1389

@leotm

Description

@leotm

Bug Description

Hermes suppresses async generators are unsupported errors in imported files

if (compile_ && ESTree::isAsync(node) && ESTree::isGenerator(node)) {
sm_.error(node->getSourceRange(), "async generators are unsupported");
}

OS: Android, iOS
Platform : arm64-v8a (macOS, M2)

Steps To Reproduce

npx react-native@latest init RN07119 --version 0.71.19

npx react-native@latest init RN07214 --version 0.72.14

// file.cjs
async function* foo() {
  yield await Promise.resolve('a');
  yield await Promise.resolve('b');
  yield await Promise.resolve('c'); // remove this yield to see error in sim/emu
};
function bar() {}; // remove this fn to see error in sim/emu

// Try this example wrapped in a new Function(String.raw``)() to see error

// Hot reload any change to see error in Metro
// [Error: Exception in HostFunction: Compiling JS failed: 2:3:async generators are unsupported Buffer size 665 starts with: 5f5f642866756e6374696f6e2028676c]
// babel.config.js
module.exports = {
  ignore: [/file\.cjs/],
  presets: ['module:metro-react-native-babel-preset'],
};
// e.g. index.js, App.tsx, node_modules/react-native/Libraries/Core/InitializeCore.js
require('./file.cjs');

The Expected Behavior

Error async generators are unsupported (Android, iOS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    need more infoAwating additional info before proceeding

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions