Skip to content

Commit

Permalink
fix erroneous code path within show_sym (#38830)
Browse files Browse the repository at this point in the history
fix erroneous code path within `show_sym`

currently, `show_sym` can recur into `show(::IO, String)`, but it's a
bit "erroneous" since `is_syntactic_operator(::String)` is not defined.
  • Loading branch information
aviatesk authored Dec 14, 2020
1 parent 0d229f8 commit 6322b8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1445,12 +1445,12 @@ end
# Print `sym` as it would appear as an identifier name in code
# * Print valid identifiers & operators literally; also macros names if allow_macroname=true
# * Escape invalid identifiers with var"" syntax
function show_sym(io::IO, sym; allow_macroname=false)
function show_sym(io::IO, sym::Symbol; allow_macroname=false)
if is_valid_identifier(sym)
print(io, sym)
elseif allow_macroname && (sym_str = string(sym); startswith(sym_str, '@'))
print(io, '@')
show_sym(io, sym_str[2:end])
show_sym(io, Symbol(sym_str[2:end]))
else
print(io, "var", repr(string(sym)))
end
Expand Down

0 comments on commit 6322b8c

Please sign in to comment.