Skip to content

[Bug]: Function Statements Require a Function Name #14401

@clhiker

Description

@clhiker

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

const v0 = [
    {
        5: 'foo',
        v20(val, x) {
            let v1 = {};
            v4(8, 'a', 7, 3, 'a');
            (() => {
                array[args]++;
                return f2[v14(10, true).attr.v6 - 2](y[2].attr);
            })().map(c, v0).map++;
        },
        null: 'a'
    },
    {
        name: 'Hugo',
        age: 8
    },
    {
        name: 'Sunny',
        age: 1
    }
];

Here is the REPL

Configuration file name

babel.config.json

Configuration

{
  "sourceType": "unambiguous",
  "presets": ["@babel/preset-env"],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}

Current and expected behavior

There is an error about self-executing function with arrow function transformed by babel.
Specifically, the original code can be run by node correctly, but there is an error transformed by babel as follows when run by node

function () {
    ^^^^^^^^

SyntaxError: Function statements require a function name

Environment

  • babel
    • ├── @babel/cli@7.17.0=6
    • ├── @babel/generator@7.17.3
    • ├── @babel/plugin-transform-runtime@7.17.0
    • ├── @babel/preset-env@7.16.11
  • Node: [v17.3.0]
  • npm version [8.5.2]
  • os [ubuntu 20.04]

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions