Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix caret bug #333 #347

Merged
merged 7 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ function is_nested_fun(x::Expr)
x.head === :call &&
length(x.args) == 2 &&
is_call(x.args[2]) &&
# Don't count `^(x)`
onearg(x, :^) == false &&
# AsTable(:x) or `$(:x)`
return get_column_expr(x.args[2]) === nothing
end
Expand Down Expand Up @@ -134,6 +136,7 @@ is_simple_non_broadcast_call(x) = false
function is_simple_non_broadcast_call(expr::Expr)
expr.head == :call &&
length(expr.args) >= 2 &&
onearg(expr, :^) == false &&
composed_or_symbol(expr.args[1]) &&
all(a -> get_column_expr(a) !== nothing, expr.args[2:end])
end
Expand Down
20 changes: 20 additions & 0 deletions test/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,24 @@ end

end

@testset "caret bug #333" begin
df = DataFrame(a = 1)
res = DataFrame(a = 1, b_sym = :xxx)
df2 = @transform df :b_sym = ^(:xxx)
@test df2 == res
df2 = @select df begin
:a
:b_sym = ^(:xxx)
end
@test df2 == res
df2 = @rsubset df begin ^(true) end
@test df2 == df
@eval df = DataFrame(a = 1)
# Some errors when we dont have keyword arguments, since
# the following gets parsed as (a^b) and we want
# (a, b...) in @subset and (a, b) in @with
@test_throws MethodError @eval @rsubset df ^(true)
@test_throws LoadError @eval @with df ^(true)
end

end # module