Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4886

Nested maps should not shadow variables

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Builders
    • Labels:
      None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      The following code fails:

      array2d.map(a -> a.map(b -> a.sum(v -> v))) 

      The code should set each cell in the row to the sum of the entire row. But because we re-use "$$this" as the variable, "a" in "a.sum" will actually refer to "b". That is, there is inappropriate shadowing of "a". Instead of using "$$this", we should use "var1", 2,3.. etc., such that the N is one higher than the N used by any sub-expression (max of all sub-expressions, + 1).

            Assignee:
            Unassigned Unassigned
            Reporter:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: