Skip to content

Commit 8d953e1

Browse files
authored
Fix rebasing bug for Meta.reescape (#59409)
Addresses #58905 (comment).
1 parent 100ef9d commit 8d953e1

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

base/meta.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,11 @@ This is the inverse operation of [`unescape`](@ref) - if the original expression
636636
was escaped, the unescaped expression is wrapped in `:escape` again.
637637
"""
638638
function reescape(@nospecialize(unescaped_expr), @nospecialize(original_expr))
639-
if isexpr(original_expr, :escape) || isexpr(original_expr, :var"hygienic-scope")
639+
if isexpr(original_expr, :escape)
640640
return reescape(Expr(:escape, unescaped_expr), original_expr.args[1])
641+
elseif isexpr(original_expr, :var"hygienic-scope")
642+
next, ctx... = original_expr.args
643+
return reescape(Expr(:var"hygienic-scope", unescaped_expr, ctx...), next)
641644
else
642645
return unescaped_expr
643646
end

stdlib/InteractiveUtils/src/macros.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@ function reescape(f::Function, @nospecialize ex)
2626
isa(ex, Expr) || return f(ex)
2727
unescaped = Meta.unescape(ex)
2828
new = f(unescaped)
29-
return reescape(new, ex)
30-
end
31-
32-
function reescape(@nospecialize(unescaped_expr), @nospecialize(original_expr))
33-
if isexpr(original_expr, :escape)
34-
return reescape(Expr(:escape, unescaped_expr), original_expr.args[1])
35-
elseif isexpr(original_expr, :var"hygienic-scope")
36-
return reescape(Expr(:var"hygienic-scope", unescaped_expr, original_expr.args[2]), original_expr.args[1])
37-
else
38-
return unescaped_expr
39-
end
29+
return Meta.reescape(new, ex)
4030
end
4131

4232
get_typeof(ex::Ref) = ex[]

0 commit comments

Comments
 (0)