Skip to content

Conversation

@fhinkel
Copy link
Member

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-botnodejs-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
MemberAuthor

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

src/node.cc Outdated
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.

@fhinkelfhinkel changed the title src: EnvDelete behaves like the delete operatorsrc: make EnvDelete behave like the delete operatorAug 4, 2016
src/node.cc Outdated
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
MemberAuthor

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

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. Fixesnodejs#7960
@addaleax
Copy link
Member

@cjihrig
Copy link
Contributor

LGTM

2 similar comments
@bnoordhuis
Copy link
Member

LGTM

@jasnell
Copy link
Member

LGTM

@jasnell
Copy link
Member

@addaleax ... does this LGTY?

@addaleax
Copy link
Member

Yes, LGTM! :)

@jasnell
Copy link
Member

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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@jasnell
Copy link
Member

Landed in ff7a841! thank you @fhinkel!

@jasnelljasnell closed this Aug 5, 2016
@cjihrigcjihrig 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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@cjihrigcjihrig 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
MemberAuthor

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 freeto 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

@fhinkel@bnoordhuis@addaleax@cjihrig@jasnell@MylesBorins@nodejs-github-bot