Skip to content

Commit

Permalink
Fix caret bug #333 (#347)
Browse files Browse the repository at this point in the history
* fix problem

* Fix #328 parsing bug try 2 (#346)

* simpler diff

* hygiene

* better fix

* update versions

* improve subsetting explanations (#345)

* Update TagBot.yml (#350)

* update news and version (#353)

* add tests

---------

Co-authored-by: Bogumił Kamiński <[email protected]>
Co-authored-by: Carlo Lucibello <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2023
1 parent 3c5ba5f commit 03d5d98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 03d5d98

Please sign in to comment.