@@ -813,7 +813,16 @@ show_unquoted(io::IO, sym::Symbol, ::Int, ::Int) = print(io, sym)
813813show_unquoted (io:: IO , ex:: LineNumberNode , :: Int , :: Int ) = show_linenumber (io, ex. line, ex. file)
814814show_unquoted (io:: IO , ex:: LabelNode , :: Int , :: Int ) = print (io, ex. label, " : " )
815815show_unquoted (io:: IO , ex:: GotoNode , :: Int , :: Int ) = print (io, " goto " , ex. label)
816- show_unquoted (io:: IO , ex:: GlobalRef , :: Int , :: Int ) = print (io, ex. mod, ' .' , ex. name)
816+ function show_unquoted (io:: IO , ex:: GlobalRef , :: Int , :: Int )
817+ print (io, ex. mod)
818+ print (io, ' .' )
819+ quoted = ! isidentifier (ex. name)
820+ parens = quoted && ! isoperator (ex. name)
821+ quoted && print (io, ' :' )
822+ parens && print (io, ' (' )
823+ print (io, ex. name)
824+ parens && print (io, ' )' )
825+ end
817826
818827function show_unquoted (io:: IO , ex:: Slot , :: Int , :: Int )
819828 typ = isa (ex,TypedSlot) ? ex. typ : Any
@@ -908,11 +917,29 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
908917 if ! emphstate && ex. typ === Any
909918 show_type = false
910919 end
920+ unhandled = false
911921 # dot (i.e. "x.y"), but not compact broadcast exps
912- if head === :(.) && ! is_expr (args[2 ], :tuple )
913- func_prec = operator_precedence (head)
914- args_ = (args[1 ], (is_quoted (arg) && ! is_quoted (unquoted (arg)) ? unquoted (arg) : arg for arg in args[2 : end ]). .. )
915- show_list (io, args_, head, indent, func_prec)
922+ if head === :(.) && (length (args) != 2 || ! is_expr (args[2 ], :tuple ))
923+ if length (args) == 2 && is_quoted (args[2 ])
924+ item = args[1 ]
925+ # field
926+ field = unquoted (args[2 ])
927+ parens = ! is_quoted (item) && ! (item isa Symbol && isidentifier (item))
928+ parens && print (io, ' (' )
929+ show_unquoted (io, item, indent)
930+ parens && print (io, ' )' )
931+ # .
932+ print (io, ' .' )
933+ # item
934+ parens = ! (field isa Symbol)
935+ quoted = parens || isoperator (field)
936+ quoted && print (io, ' :' )
937+ parens && print (io, ' (' )
938+ show_unquoted (io, field, indent)
939+ parens && print (io, ' )' )
940+ else
941+ unhandled = true
942+ end
916943
917944 # infix (i.e. "x <: y" or "x = y")
918945 elseif (head in expr_infix_any && nargs== 2 ) || (head === :(:) && nargs== 3 )
@@ -1236,6 +1263,9 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
12361263 show_type = false
12371264 # print anything else as "Expr(head, args...)"
12381265 else
1266+ unhandled = true
1267+ end
1268+ if unhandled
12391269 if head != = :invoke
12401270 show_type = false
12411271 end
0 commit comments