GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — repl: warn on assignment to _ by cjihrig · Pull Request #5438 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Feb 25, 2016

Copy link
Copy Markdown
Contributor

Pull Request check-list

  • Does make -j8 test (UNIX) or vcbuild test nosign (Windows) pass with
    this change (including linting)?
  • Is the commit message formatted according to [CONTRIBUTING.md][0]?
  • If this change fixes a bug (or a performance problem), is a regression
    test (or a benchmark) included?
  • Is a documentation update included (if this change modifies
    existing APIs, or introduces new ones)?

Affected core subsystem(s)

repl

Description of change

The REPL uses _ to store the result of the previous expression. This can cause confusion for REPL users who assign libraries like Underscore and Lodash to _. The documentation already mentions this behavior. This commit adds a printed warning if the user assigns to _.

Refs: #5431

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cjihrig
repl: warn on assignment to _
0560edf
The REPL uses _ to store the result of the previous expression.
This can cause confusion for REPL users who assign libraries like
Underscore and Lodash to _. The documentation already mentions
this behavior. This commit adds a printed warning if the user
assigns to _.
@silverwind silverwind added the repl Issues and PRs related to the REPL subsystem. label Feb 25, 2016
@rvagg rvagg mentioned this pull request Feb 26, 2016
assigning _ in the repl has side effects #5431
Closed
@rvagg

rvagg commented Feb 26, 2016

Copy link
Copy Markdown
Member

How does this interact with #3737, is it one or the other?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Feb 26, 2016

Copy link
Copy Markdown
Contributor Author

@rvagg it looks like this subsumes #3737. I'm also seeing a few different behaviors, depending on the type of variable:

  • const - In master, const _ = 3; throws a TypeError trying to assign a read only property. In repl: assign underscore fix #3737 and this PR, a different TypeError is thrown that _ is already declared.
  • let - In master, repl: assign underscore fix #3737, and this PR, a let variable takes over _ completely.
  • var or global - This PR displays a warning on assignment. repl: assign underscore fix #3737 and master silently assign.

I think the varying behavior is related to #983.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented Feb 27, 2016

Copy link
Copy Markdown
Contributor

Can't say I like this approach. I'd rather see something like #5431 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig closed this Feb 29, 2016
@lance lance mentioned this pull request Mar 7, 2016
repl: Assignment of _ allowed with warning #5535
Closed
4 tasks done
This was referenced Oct 14, 2022
[Snyk] Upgrade @npmcli/arborist from 4.3.1 to 5.6.2 verdinjoshua1982/node#1
Open
[Snyk] Upgrade libnpmexec from 3.0.3 to 4.0.13 verdinjoshua1982/node#5
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

repl Issues and PRs related to the REPL subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cjihrig @rvagg @silverwind
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.