[SERVER-4051] Map functions have unusual scoping rules Created: 10/Oct/11  Updated: 11/Oct/11  Resolved: 11/Oct/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Michael Stillwell Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

The following code, when pasted into the shell, yields the error message "map invoke failed: JS Error: ReferenceError: qqqqqq is not defined nofile_b:1" even though the variable "qqqqqq" has the value "Clem" when the map function is run.

example.js

var m = function(qqqqqq) {
    return function() {
        emit("foo", qqqqqq);
    };
};
 
var r = function(k, v) { return {} };
 
db.tmp.save({});
db.tmp.mapReduce(
    m("Clem"), r, 
    { "out": "tmp" }
);



 Comments   
Comment by Eliot Horowitz (Inactive) [ 11/Oct/11 ]

See SERVER-150

Generated at Thu Feb 08 03:04:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.