insist
insist copied to clipboard
In REPL, TypeError: Cannot read property 'toString' of undefined
Testing insist with io.js 2.1.0 in the REPL:
# iojs
> let assert = require('insist');
undefined
> assert.equal(3, 4);
TypeError: Cannot read property 'toString' of undefined
at getMessage (/mnt/devdrive/NodeProjects/asserttests/node_modules/insist/insist.js:84:21)
at Function.insist (/mnt/devdrive/NodeProjects/asserttests/node_modules/insist/insist.js:96:22)
at repl:1:8
at REPLServer.defaultEval (repl.js:155:27)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:309:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:208:10)
trace.fun
is undefined
at https://github.com/seanmonstar/insist/blob/2f8d497cf58d7a6c978565a0b1ab8eda8529c0cc/insist.js#L84 and I don't know why. This happens even if I move the assert into a function in the REPL.
Er, should it even be trace.fun
? Looking at stack-trace, it seems trace.getFunction()
would be the right way? If that works, would you mind filing a PR?
That does not work. I was about to file a PR, when I tested this in the console. Using let
is doing something to the CallSite object, not sure what, but it does not matter if substituting fun
for getFunction()
. I tried ... Substituting let
for var
in the example will run just fine, btw.
This bug only manifests itself in the REPL btw, so to test it one can do this:
$ iojs --use-strict -i << EOF
> let assert = require('./insist');
> assert.equal(3, 4);
> let assert = require('./insist');
undefined
> assert.equal(3, 4);
TypeError: Cannot read property 'toString' of undefined
at getMessage (/Users/carl-erik.kopseng/dev-priv/insist/insist.js:84:31)
at Function.insist [as equal] (/Users/carl-erik.kopseng/dev-priv/insist/insist.js:99:22)
at repl:1:8
at REPLServer.defaultEval (repl.js:164:27)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:392:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
>
I see that better-assert
does this fine, so maybe a fix could be to use tj/callsite like it does? Might change the look of the stacktraces, though.