Issue 1:
There is a weird compile behaviour that should not happen. Consider the function:

@inline function num_unique(group_str::AbstractString)
return group_str |> Set |> length
end

That is used in a super function (with two variants and their output and lowered code). Variant 1:

function sum_unique1(group_strs::Vector{<:AbstractString})
# clump groups to one line before adding to set (removes the need for union)
f = x -> replace(x, "\n" => "")
return group_strs .|> f .|> num_unique |> sum
end

Output of variant 1 with some string vector as input:

sum_unique1(group_strs) = 6703

Lowered code for variant 1:

@code_lowered sum_unique1(["abaz\nasd", "ashds\ndshgs"])
CodeInfo(
1 ─ #23 = %new(Main.:(var"#23#24"))
│ f = #23
│ %3 = Base.broadcasted(Main.:|>, group_strs, f)
│ %4 = Base.broadcasted(Main.:|>, %3, Main.num_unique)
│ %5 = Base.materialize(%4)
│ %6 = %5 |> Main.sum
└── return %6
)

Now the okay-looking variant 2:

function sum_unique2(group_strs::Vector{<:AbstractString})
# clump groups to one line before adding to set (removes the need for union)
return group_strs .|> x -> replace(x, "\n" => "") .|> num_unique |> sum
end

Output of variant 2:

sum_unique2(group_strs) = [3, 16, 22, 22, ...] # is the output array where sum(output array) = 6703

Lowered code of variant 2:

@code_lowered sum_unique2(["abaz\nasd", "ashds\ndshgs"])
CodeInfo(
1 ─ #27 = %new(Main.:(var"#27#28"))
│ %2 = #27
│ %3 = Base.broadcasted(Main.:|>, group_strs, %2)
│ %4 = Base.materialize(%3)
└── return %4 # doesn't even call sum and just exits!
)

This lowered code can be reproduced for the following function:

function sum_unique(group_strs::Vector{<:AbstractString})
return group_strs .|> (x -> replace(x, "\n" => "") .|> num_unique |> sum)
end

Lowered code which is identical to the above "flawed" variant sum_unique2():

@code_lowered sum_unique(["abaz\nasd", "ashds\ndshgs"])
CodeInfo(
1 ─ #11 = %new(Main.:(var"#11#12"))
│ %2 = #11
│ %3 = Base.broadcasted(Main.:|>, group_strs, %2)
│ %4 = Base.materialize(%3)
└── return %4
)

Therefore the sum here was hidden inside the anonymous function and the output didn't change because of summing over a scalar. Also, interestingly, this problem goes away if chaining is done inside broadcasted function num_unique like below:

@inline function num_unique(group_str::AbstractString)
# clump groups to one line before adding to set (removes the need for union)
return group_str |> x -> replace(x, "\n" => "") |> Set |> length
end

And just wrapping the anonymous function in parenthesis also does the trick (of solving this issue):

function sum_unique(group_strs::Vector{<:AbstractString})
# clump groups to one line before adding to set (removes the need for union)
return group_strs .|> (x -> replace(x, "\n" => "")) .|> num_unique |> sum
end

But these ways of getting around this problem essentially express the same code (or should!). It will be great if this can be investigated a bit more. I am very new to Julia, so I haven't been able to go deeper (yet).

My Julia version info is below:

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, ivybridge)
Environment:
JULIA_EDITOR = "/snap/code/51/usr/share/code/code"
JULIA_NUM_THREADS =

Issue 2:
Issue

Doing

data .|> x -> f(x, 2) .|> g

expands to

data .|> x -> (f(x,2) .|> g)

but should expand to

data .|> (x -> f(x,2)) .|> g

Workaround

Add parentheses