Skip to content

🐛panic when trying to fix 'Redundant use strict directive' - crates\biome_js_formatter\src\utils\string_utils.rs:164:33 - byte index 1 is out of bounds of #9180

@Araxeus

Description

@Araxeus

Environment information

Details
CLI:
  Version:                      2.4.4
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           v25.2.1
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false
  HTML full support enabled:    unset

Workspace:
  Open Documents:               0

What happened?

Try to fix a file that has 'use strict';
for example save this as test.js:

'use strict';
console.log('this is going to panic');
`biome check` output

test.js:1:1 lint/suspicious/noRedundantUseStrict  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ! Redundant use strict directive.

  > 1 │ 'use strict';
      │ ^^^^^^^^^^^^^
    2 │

  i The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.

  i Safe fix: Remove the redundant use strict directive.

    1 │ 'use·strict';␍
      │ -------------

$ RUST_BACKTRACE=1 biome check --write
Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue.

When opening the issue, please provide a minimal reproduction, or identify and share the file/code that triggers it. Without a way to reproduce the error, the error can't be fixed:

Source Location: crates\biome_js_formatter\src\utils\string_utils.rs:164:33
Thread Name: biome::workspace_worker_4
Message: byte index 1 is out of bounds of ``
Stack Trace:
   0: <unknown>
   ... same until 49
  49: <unknown>
  50: BaseThreadInitThunk
  51: RtlUserThreadStart

test.js internalError/panic  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × processing panicked: byte index 1 is out of bounds of ``

  ! This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary.

Expected result

should not panic

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

S-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions