Skip to content

Strangeness in error message when node gives call stack, if error had occured in specially declared function #8322

Closed
@nickkolok

Description

@nickkolok

MWE:

nickolaus@nicknout:~/git/fraction.js$ js
> var obj = {};
undefined
> obj.a = obj.b = function(){throw err};
[Function]
> obj.b();
ReferenceError: err is not defined
    at Object.obj.a.obj.b (repl:1:34)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.a();
ReferenceError: err is not defined
    at Object.obj.a.obj.b (repl:1:34)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> 

The strangeness is at Object.obj.a.obj.b (repl:1:34)

Pure MWE JS:

var obj = {};
obj.a = obj.b = function(){throw err};
obj.b();

Is it an error?

If the same object is declared in another way, everything is OK:

> var obj = {};
undefined
> obj.b = function(){throw err};
[Function]
> obj.a = obj.b;
[Function]
> obj.a();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.b();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions