Skip to content

[Bug]: arithmetic overflow occurred while processing enums #15410

@kaikaibenkai

Description

@kaikaibenkai

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

export enum Permission {
  'CREATE_INSTANT_INVITE' = 1 << 0,
  'KICK_MEMBERS' = 1 << 1,
  // ...
  'USE_PRIVATE_THREADS' = 1 << 36,
  'USE_EXTERNAL_STICKERS' = 1 << 37,
}

Configuration file name

No response

Configuration

This problem exists in any configuration.

Current and expected behavior

Current: it will overflow if the value <= 2^31

export let Permission;
(function (Permission) {
  Permission[Permission["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
  Permission[Permission["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
  Permission[Permission["USE_PRIVATE_THREADS"] = 16] = "USE_PRIVATE_THREADS";
  Permission[Permission["USE_EXTERNAL_STICKERS"] = 32] = "USE_EXTERNAL_STICKERS";
})(Permission || (Permission = {}));

Excepted:

Environment

  • Babel: 7.19.0
  • Node: 16.16.0
  • Npm: 8.19.2
  • Yarn: 1.22.19

Possible solution

Using number in JavaScript for operation?

Additional context

I use it online

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: questionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions