hydromatic / morel

Standard ML interpreter, with relational extensions, implemented in Java
Apache License 2.0
291 stars 15 forks source link

`FromBuilder` should remove trivial `yield` step between two `scan` steps #208

Closed julianhyde closed 6 months ago

julianhyde commented 6 months ago

FromBuilder should remove trivial yield between two scans. For example, the query

from i in [1, 2] yield {i} join j in [3, 4]

has a yield after a scan that defines i and before a scan that defines j. The yield is trivial because it returns a record with all variables in scope (just i) and therefore it should simplify to

from i in [1, 2] yield {i} join j in [3, 4]

But it does not remove the yield. At the point where it checks whether the yield is trivial, FromBuilder has already (wrongly) added j to the scope and therefore does not think yield {i} is trivial.