Skip to content

Commit a3d647d

Browse files
committed
Fix small bug from #16 so tests pass
The change lifted the scope of `note`, so it was being changed in the loop
1 parent 3c3a646 commit a3d647d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/utils.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ function showprov(io::IO, exs::AbstractVector;
4747
print(io, "\n\n")
4848
end
4949
k = kind(ex)
50-
if isnothing(note) # use provided `note` otherwise
51-
note = i > 1 && k == K"macrocall" ? "in macro expansion" :
52-
i > 1 && k == K"$" ? "interpolated here" :
53-
"in source"
54-
end
55-
highlight(io, sr; note=note, highlight_kwargs...)
50+
ex_note = !isnothing(note) ? note :
51+
i > 1 && k == K"macrocall" ? "in macro expansion" :
52+
i > 1 && k == K"$" ? "interpolated here" :
53+
"in source"
54+
highlight(io, sr; note=ex_note, highlight_kwargs...)
5655

5756
if include_location
5857
line, _ = source_location(sr)

test/quoting.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ end
4747
end
4848
end
4949
# @ string:5"""
50+
@test sprint(io->showprov(io, ex[1][3]; note="foo")) == raw"""
51+
begin
52+
x = 10
53+
y = :(g(z))
54+
# └──┘ ── foo
55+
quote
56+
f($(x+1), $y)
57+
# @ string:3
58+
59+
y = :(g(z))
60+
quote
61+
f($(x+1), $y)
62+
# └┘ ── foo
63+
end
64+
end
65+
# @ string:5"""
5066

5167

5268
# Test expression flags are preserved during interpolation

0 commit comments

Comments
 (0)