src: disallow constructor behaviour for native methods#26700
src: disallow constructor behaviour for native methods#26700addaleax wants to merge 2 commits intonodejs:masterfrom
Conversation
Disallow constructor behaviour and setting up prototypes for native methods that are not constructors (i.e. make them behave like ES6 class methods).
| common.expectsError(function() { process.chdir(); }, err); | ||
|
|
||
| // Check that our built-in methods do not have a prototype/constructor behaviour | ||
| // if they don't need to. This could be tested for any of our C++ methods. |
There was a problem hiding this comment.
This could be tested for any of our C++ methods.
Maybe it doesn't matter, but the one picked here means this isn't tested in Worker threads.
There was a problem hiding this comment.
Yeah, I’d say it doesn’t matter – these things are pretty independent, and I’ve chosen something that is likely to stay a directly C++-backed method for a long time. I’m happy to take other suggestions, though.
|
Nice, but what about @joyeecheung's assertion:
That's why I didn't do it in #26096, I felt like it should be firstly investigated if some modules rely on some methods/functions being constructors. |
@Hakerh400 We can run our ecosystem checking tool on this, but generally, this should be safe to do. None of the methods affected by this are likely to be used as constructors, and I’m not concerned that there could be significant ecosystem usage of this. Plus, this won’t be released until Node 12. |
|
Landed in 1935625 |
Disallow constructor behaviour and setting up prototypes for native methods that are not constructors (i.e. make them behave like ES6 class methods). PR-URL: #26700 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Disallow constructor behaviour and setting up prototypes
for native methods that are not constructors (i.e. make
them behave like ES6 class methods).
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes