Skip to content

Commit be7d4ad

Browse files
authored
fix showing keyword calls (#109)
* fix showing keyword calls * add test for kw call printing * fix on nightly
1 parent 9eeb37e commit be7d4ad

File tree

6 files changed

+100
-6
lines changed

6 files changed

+100
-6
lines changed

Manifest.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

66
[[CodeTracking]]
7-
deps = ["InteractiveUtils", "Test", "UUIDs"]
8-
git-tree-sha1 = "2c46bc2429c88b43d80caf53151f22b85ba5a4b2"
7+
deps = ["InteractiveUtils", "UUIDs"]
8+
git-tree-sha1 = "9e697f312e39a94fc9e0368672662d34b0054a43"
9+
repo-rev = "master"
10+
repo-url = "https://github.com/timholy/CodeTracking.jl.git"
911
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
10-
version = "0.3.4"
12+
version = "0.4.0"
1113

1214
[[Crayons]]
1315
deps = ["Test"]
@@ -41,7 +43,7 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
4143

4244
[[JuliaInterpreter]]
4345
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
44-
git-tree-sha1 = "1d4df77f80cb7ff450ac0c59e0b906a3713537b2"
46+
git-tree-sha1 = "1ccddcf4eac5f32aa0d559fa73dbf9b965d239fb"
4547
repo-rev = "master"
4648
repo-url = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git"
4749
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1212
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1313

1414
[compat]
15-
CodeTracking = "0.3.2"
15+
CodeTracking = "0.3.2, 0.4"
1616
Crayons = "3"
1717
Highlights = "0.3.1"
1818
JuliaInterpreter = "0.2"
@@ -23,4 +23,4 @@ TerminalRegressionTests = "98bfdc55-cc95-5876-a49a-74609291cbe0"
2323
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2424

2525
[targets]
26-
test = ["Test", "TerminalRegressionTests"]
26+
test = ["Test", "TerminalRegressionTests"]

src/Debugger.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function _make_frame(mod, arg)
8383
quote
8484
theargs = $(esc(args))
8585
frame = JuliaInterpreter.enter_call_expr(Expr(:call,theargs...))
86+
frame = JuliaInterpreter.maybe_step_through_kwprep!(frame)
8687
frame = JuliaInterpreter.maybe_step_through_wrapper!(frame)
8788
JuliaInterpreter.maybe_next_call!(frame)
8889
frame

src/printing.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ function print_frame(io::IO, num::Integer, frame::Frame)
3636
print_locals(io, frame)
3737
end
3838

39+
function pattern_match_kw_call(expr)
40+
if isexpr(expr, :call)
41+
f = string(expr.args[1])
42+
is_kw = occursin("#kw#", f) || (startswith(f, "#") && endswith(f, "_kw"))
43+
else
44+
is_kw = false
45+
end
46+
is_kw || return expr
47+
args = length(expr.args) >= 4 ? expr.args[4:end] : []
48+
kws_nt = expr.args[2]
49+
kws = []
50+
for (k, w) in pairs(kws_nt)
51+
push!(kws, Expr(:kw, k, w))
52+
end
53+
f = expr.args[3]
54+
return :($f($(args...); $(kws...)))
55+
end
3956

4057
function print_next_expr(io::IO, frame::Frame)
4158
maybe_quote(x) = (isa(x, Expr) || isa(x, Symbol)) ? QuoteNode(x) : x
@@ -57,6 +74,7 @@ function print_next_expr(io::IO, frame::Frame)
5774
expr.args[i] = maybe_quote(val)
5875
end
5976
end
77+
expr = pattern_match_kw_call(expr)
6078
if isa(expr, Expr)
6179
for (i, arg) in enumerate(expr.args)
6280
try

test/ui.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ function my_gcd_noinfo(a::T, b::T) where T<:Union{Int8,UInt8,Int16,UInt16,Int32,
4747
end
4848
""", "nope.jl")
4949

50+
51+
function outer(a, b, c, d)
52+
inner_kw(a, b; c = c)
53+
end
54+
55+
function inner_kw(a, b; c = 3, d = 10)
56+
return a + b + c + d
57+
end
58+
59+
60+
5061
@testset "UI" begin
5162
if Sys.isunix() && VERSION >= v"1.1.0"
5263
Debugger._print_full_path[] = false
@@ -72,6 +83,10 @@ end
7283
"s\n", "fr 1\n", "fr 2\n", "f 2\n", "f 1\n",
7384
"bt\n", "st\n", "C", "c\n", "C", "c\n"],
7485
"ui/history_gcd.multiout")
86+
87+
run_terminal_test(@make_frame(outer(1, 2, 5, 20)),
88+
["s\n", "c\n"],
89+
"ui/history_kw.multiout")
7590

7691
if v"1.1">= VERSION < v"1.2"
7792
run_terminal_test(@make_frame(my_gcd_noinfo(10, 20)),

test/ui/history_kw.multiout

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
++++++++++++++++++++++++++++++++++++++++++++++++++
2+
|In outer(a, b, c, d) at ui.jl:52
3+
|>52 inner_kw(a, b; c = c)
4+
| 53 end
5+
| 54
6+
| 55 function inner_kw(a, b; c = 3, d = 10)
7+
| 56 return a + b + c + d
8+
|
9+
|About to run: (inner_kw)(1, 2; c=5)
10+
|1|debug>
11+
--------------------------------------------------
12+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
13+
|BBBBBAAAAAAAAAAAAAAAAAAAAAAAAA
14+
|AAAAAAAA
15+
|AAAAA
16+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
17+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
18+
|
19+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
20+
|CCCCCCCCC
21+
++++++++++++++++++++++++++++++++++++++++++++++++++
22+
|In outer(a, b, c, d) at ui.jl:52
23+
|>52 inner_kw(a, b; c = c)
24+
| 53 end
25+
| 54
26+
| 55 function inner_kw(a, b; c = 3, d = 10)
27+
| 56 return a + b + c + d
28+
|
29+
|About to run: (inner_kw)(1, 2; c=5)
30+
|1|debug> s
31+
|In #inner_kw#13(c, d, , a, b) at ui.jl:56
32+
|>56 return a + b + c + d
33+
| 57 end
34+
| 58
35+
| 59
36+
| 60
37+
|
38+
|About to run: (+)(1, 2, 5, 10)
39+
|1|debug>
40+
--------------------------------------------------
41+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
42+
|BBBBBAAAAAAAAAAAAAAAAAAAAAAAAA
43+
|AAAAAAAA
44+
|AAAAA
45+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
46+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
47+
|
48+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
49+
|CCCCCCCCCA
50+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
51+
|BBBBBAAAAAAAAAAAAAAAAAAAAAAAA
52+
|AAAAAAAA
53+
|AAAAA
54+
|AAAAA
55+
|AAAAA
56+
|
57+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
58+
|CCCCCCCCC

0 commit comments

Comments
 (0)