-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Weird 'require' behaviour #410
Comments
broken on 0.4.0 |
The Is it too common name? |
I don't think it matters whether it is too common or not - I'd say all built-in things like that should be prefixed to avoid clashes. Something like two underscores in the beginning of the member's name; that would also help when reading the code. |
Confirmed, still happens. Can someone review 4cf91ed? |
@bnoordhuis +1, would be useful for the REPL: |
@bnoordhuis - The patch LGTM. |
Well when do you really need to -1 on changing the name. |
var util = require('util');
var a = { inspect: function() { throw new Error() } };
util.inspect(a); Please imagine that
|
Good point. On Tue, Sep 6, 2011 at 11:41 PM, Koichi Kobayashi <
|
That's step 2: deprecate inspect() in 0.6 and remove it in 0.7. I prefer |
@bnoordhuis +1 |
-1 Leave |
on a side note console.dir should ignore inspect (too small for an issue?) |
This is not a big enough issue to justify changing util.inspect. (Or, even worse! renaming it!) Closing. |
There are three files:
a.js:
b.js:
c.js:
running
produces error:
node.js:50
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'indexOf' of undefined
at util.js:187:19
at Array.map (native)
at format (util.js:162:23)
at Object.inspect (util.js:244:10)
at Object.format (node.js:501:25)
at Object. (node.js:527:31)
at Object. (/home/ci-user/dev/nimblegecko-2/a.js:3:9)
at Module._compile (node.js:348:23)
at Object..js (node.js:356:12)
at Module.load (node.js:279:25)
As soon as I rename 'inspect' into something else, all works fine.
Any ideas why?
The text was updated successfully, but these errors were encountered: