Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: make EnvDelete behave like the delete operator #7975

Closed
wants to merge 1 commit into from

Conversation

fhinkel
Copy link
Member

@fhinkel fhinkel commented Aug 4, 2016

Checklist
  • make -j4 test (UNIX) passes
  • tests and/or benchmarks are included
  • documentation is changed or added: our docs don't specify the return value of delete in the example
  • commit message follows commit guidelines
Affected core subsystem(s)

src

Description of change

According to TC39 specification, the delete
operator returns false or throws
in strict mode, if the property is
non-configurable. It returns true in all other cases.

Process.env can never have non-configurable
properties, thus EnvDelete must always return true. This
is independent of strict mode.

Fixes #7960

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Aug 4, 2016
@fhinkel
Copy link
Member Author

fhinkel commented Aug 4, 2016

This changes observable behavior of delete process.env. Does that make it a semver-major change?

#ifdef __POSIX__
node::Utf8Value key(info.GetIsolate(), property);
rc = getenv(*key) != nullptr;
if (rc)
bool has_key = getenv(*key) != nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could fold this into the if statement.

@bnoordhuis
Copy link
Member

Can you reword the commit log so it says "src: make EnvDelete etc etc"? As to whether this should be semver-major or not, I personally lean towards bug fix.

@fhinkel fhinkel changed the title src: EnvDelete behaves like the delete operator src: make EnvDelete behave like the delete operator Aug 4, 2016
#ifdef __POSIX__
node::Utf8Value key(info.GetIsolate(), property);
rc = getenv(*key) != nullptr;
if (rc)
if (getenv(*key) != nullptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check even necessary anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, according to unsetenv(3) no need for it. I'm assuming unsetenv() is not slower than doing the getenv() check first.

@addaleax
Copy link
Member

addaleax commented Aug 4, 2016

Got a question but otherwise this is looking good!

According to TC39 specification, the delete
operator returns false or throws
in strict mode, if the property is
non-configurable. It returns true in all other cases.

Process.env can never have non-configurable
properties, thus EnvDelete must always return true. This
is independent of strict mode.

Fixes nodejs#7960
@addaleax
Copy link
Member

addaleax commented Aug 4, 2016

@cjihrig
Copy link
Contributor

cjihrig commented Aug 4, 2016

LGTM

2 similar comments
@bnoordhuis
Copy link
Member

LGTM

@jasnell
Copy link
Member

jasnell commented Aug 4, 2016

LGTM

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

@addaleax ... does this LGTY?

@addaleax
Copy link
Member

addaleax commented Aug 5, 2016

Yes, LGTM! :)

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

Awesome, thank you! will get this landed now.

jasnell pushed a commit that referenced this pull request Aug 5, 2016
According to TC39 specification, the delete
operator returns false or throws
in strict mode, if the property is
non-configurable. It returns true in all other cases.

Process.env can never have non-configurable
properties, thus EnvDelete must always return true. This
is independent of strict mode.

Fixes: #7960
PR-URL: #7975
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

Landed in ff7a841! thank you @fhinkel!

@jasnell jasnell closed this Aug 5, 2016
@cjihrig cjihrig mentioned this pull request Aug 8, 2016
cjihrig pushed a commit that referenced this pull request Aug 10, 2016
According to TC39 specification, the delete
operator returns false or throws
in strict mode, if the property is
non-configurable. It returns true in all other cases.

Process.env can never have non-configurable
properties, thus EnvDelete must always return true. This
is independent of strict mode.

Fixes: #7960
PR-URL: #7975
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@cjihrig cjihrig mentioned this pull request Aug 11, 2016
@MylesBorins
Copy link
Contributor

adding lts watch label. please let me know if this should be landed or not

@fhinkel
Copy link
Member Author

fhinkel commented Sep 30, 2016

Not sure. My feeling is we don't need this fix in v4.

@MylesBorins
Copy link
Contributor

moving to don't land

thanks @fhinkel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnvDeleter should return true
7 participants