hissssst / tria

Elixir optimizing compiler
GNU General Public License v3.0
55 stars 2 forks source link

Extra evaluation with Enum fusion #3

Closed sabiwara closed 1 year ago

sabiwara commented 1 year ago

Hi @hissssst , congratulations on the release! 🎉

I noticed a potential issue with Enum fusion:

  def hello_world do
    1..3
    |> Enum.map(&IO.inspect(&1, label: "hello"))
    |> Enum.map(&IO.inspect(&1, label: "world"))
    |> Enum.sum()
  end
iex> Foo.hello_world
hello: 1
hello: 1
world: 1
hello: 2
hello: 2
world: 2
hello: 3
hello: 3
world: 3
6

Expected behavior: only one call to hello on each pass.

hissssst commented 1 year ago

Hi, thanks for this good catch!