Skip to content

REPL preview causes unwanted side effects like deletion of unexpected objects #59735

@ptomato

Description

@ptomato

Version

24.7.0

Platform

Linux hostname 6.14.11-300.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 10 16:24:16 UTC 2025 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  • Start an interactive REPL session
  • Type delete globalThis._ but don't press enter
  • Backspace until the line is empty
  • Type globalThis and press enter

How often does it reproduce? Is there a required condition?

Reliably reproducible. The REPL preview needs to be enabled; it does not reproduce with TERM=dumb. Not reproducible with 22.18.0.

What is the expected behavior? Why is that the expected behavior?

I would expect that the delete expression doesn't actually cause any deletion during evaluation for the preview. Failing that, I would expect that _ (which initially doesn't exist) would be deleted from the global scope.

What do you see instead?

> globalThis
Uncaught ReferenceError: globalThis is not defined

The globalThis object is actually deleted.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions