Lazy.jl's `@>` not working as expected when working with FileIO.jl

using Lazy
@> begin
    1:2
    sum
end

the above to be the same as calling

sum(1:2)

Now I want to use it together with FileIO.jl

using FileIO, DataFrame, Lazy, CSV

a = DataFrame(a = 1)
CSV.write("file.csv", a)

data = @> begin    
    "file.csv"
    load
end

but this returns FileIO.load instead of load("file.csv").

I can fix it by doing

data = @> "file.csv" begin    
    load
end

But why doesn’t the first way work?

It is interpreting it as that you want to document the variable load.

julia> Meta.parse(""" "file.csv"
                       load""")
:(#= none:1 =# Core.:(@doc) "file.csv" load)

julia> var = 3
3

julia> "this is docs for var"
       var
var

help?> var
search: var Vararg varinfo TypeVar UndefVarError

  this is docs for var

This happens before the Lazy macro has a change to see the expression.

4 Likes

I see. This would be a really bug for beginners to catch!!!