title: Join inherited scope with by in data.table
body: <p>I'm on data.table 1.9.3, and maybe I'm wrong, but I don't recall the
  following to be expected previously.</p>
  
  <p>I build 2 data.tables, dta and dtb</p>
  
  <pre><code>&gt; dta
     idx vala fdx
  1:   1    2   a
  2:   2    4   a
  3:   3    6   b
  
  &gt; dtb
     idx valb
  1:   1    3
  2:   4    6
  
  &gt; dput(x = dta)
  structure(list(idx = c(1, 2, 3), vala = c(2, 4, 6), fdx = c("a",
  "a", "b")), .Names = c("idx", "vala", "fdx"), row.names = c(NA,
  -3L), class = c("data.table", "data.frame"), .internal.selfref =
  &lt;pointer: 0x0000000000110788&gt;, sorted = "idx")
  
  &gt; dput(x = dtb)
  structure(list(idx = c(1, 4), valb = c(3, 6)), .Names = c("idx",
  "valb"), row.names = c(NA, -2L), class = c("data.table", "data.frame"
  ), .internal.selfref = &lt;pointer: 0x0000000000110788&gt;, sorted = "idx")
  </code></pre>
  
  <p>The key is idx in both cases.</p>
  
  <p>The following works, of course</p>
  
  <pre><code>&gt; dta[dtb, sum(valb)]
  [1] 9
  </code></pre>
  
  <p>However this doesn't</p>
  
  <pre><code>&gt; dta[dtb, sum(valb), by = fdx]
  Error in `[.data.table`(dta, dtb, sum(valb), by = fdx) :
    object 'valb' not found
  </code></pre>
  
  <p>But this does</p>
  
  <pre><code>&gt; dta[dtb][, sum(valb), by = fdx]
     fdx V1
  1:   a  3
  2:  NA  6
  </code></pre>
  
  <p>If we see the intermediate step</p>
  
  <pre><code>&gt; dta[dtb]
     idx vala fdx valb
  1:   1    2   a    3
  2:   4   NA  NA    6
  </code></pre>
  
  <p>I would have expected </p>
  
  <pre><code>dta[dtb, sum(valb), by = fdx] == dta[dtb][, sum(valb), by = fdx]
  </code></pre>
  
  <p>Where have I gone wrong?</p>