Skip to content

Commit ff86e51

Browse files
committed
fix #5
1 parent f59ed8a commit ff86e51

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/JuliaVariables.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ function solve(ana, ex, ctx_flag::CtxFlag = CtxFlag())
318318
Expr(:tuple, args...)
319319
end
320320
# keyword arguments for tuples or calls
321-
Expr(:kw, k::Symbol, v) => Expr(:kw, k, solve(ana, v, ctx_flag + :rhs))
321+
Expr(:kw, k::Symbol, v) =>
322+
begin
323+
if ctx_flag.default_scope == Arg()
324+
solve(ana, k, ctx_flag)
325+
end
326+
Expr(:kw, k, solve(ana, v, ctx_flag + :rhs))
327+
end
322328
# broadcasting symbols
323329
Expr(:call, f :: Symbol, args...) &&
324330
if length(args) in (1, 2) && is_broadcast_sym(f)

test/runtests.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using JuliaVariables
22
using Test
33
using NameResolution
4+
using MLStyle
45

56
rmlines = JuliaVariables.rmlines
67
JuliaVariables.@quick_lambda begin
@@ -62,5 +63,23 @@ JuliaVariables.@quick_lambda begin
6263

6364
a = solve(:(2 .^ [2, 3]))
6465
@test eval(a) == [4, 8]
66+
67+
a = solve(:(function z(x, k=1)
68+
x + 20 + a + k
69+
end
70+
))
71+
@test haskey(a.scope.bounds, :k)
72+
73+
a = solve(:(function z(x, k=1)
74+
(k=k, )
75+
end
76+
))
77+
@test haskey(a.scope.bounds, :k)
78+
79+
@test @when :(k=$_, ) = a.func.args[2].args[2] begin
80+
true
81+
@otherwise
82+
false
83+
end
6584
end
6685
end

0 commit comments

Comments
 (0)