Skip to content

Commit

Permalink
Use lowered form in logging macro (#26291)
Browse files Browse the repository at this point in the history
Macro hygiene sees pre-lowered forms, and as a result does not apply
to syntactic forms like []. Use an explicit `getindex` to get the
proper hygiene behavior.

Fixes #26273
  • Loading branch information
Keno authored and JeffBezanson committed Mar 2, 2018
1 parent d480d1b commit d1aa8f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function logmsg_code(_module, file, line, level, message, exs...)
quote
level = $level
std_level = convert(LogLevel, level)
if std_level >= _min_enabled_level[]
if std_level >= getindex(_min_enabled_level)
logstate = current_logstate()
if std_level >= logstate.min_enabled_level
logger = logstate.logger
Expand Down
8 changes: 8 additions & 0 deletions test/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,12 @@ end
"""
end

# Issue #26273
let m = Module(:Bare26273i, false)
eval(m, :(import Base: @error))
@test_logs (:error, "Hello") eval(m, quote
@error "Hello"
end)
end

end

0 comments on commit d1aa8f7

Please sign in to comment.