@@ -628,21 +628,27 @@ JL_DLLEXPORT jl_value_t *jl_argument_datatype(jl_value_t *argt JL_PROPAGATES_ROO
628
628
return (jl_value_t * )dt ;
629
629
}
630
630
631
- static int is_globfunction (jl_value_t * v , jl_datatype_t * dv , jl_sym_t * * globname_out )
631
+ static int is_globname_binding (jl_value_t * v , jl_datatype_t * dv )
632
632
{
633
633
jl_sym_t * globname = dv -> name -> mt != NULL ? dv -> name -> mt -> name : NULL ;
634
- * globname_out = globname ;
635
- int globfunc = 0 ;
636
- if (globname && !strchr (jl_symbol_name (globname ), '#' ) &&
637
- !strchr (jl_symbol_name (globname ), '@' ) && dv -> name -> module &&
638
- jl_binding_resolved_p (dv -> name -> module , globname )) {
634
+ if (globname && dv -> name -> module && jl_binding_resolved_p (dv -> name -> module , globname )) {
639
635
jl_binding_t * b = jl_get_module_binding (dv -> name -> module , globname );
640
636
// The `||` makes this function work for both function instances and function types.
641
637
if (b && b -> value && (b -> value == v || jl_typeof (b -> value ) == v )) {
642
- globfunc = 1 ;
638
+ return 1 ;
643
639
}
644
640
}
645
- return globfunc ;
641
+ return 0 ;
642
+ }
643
+
644
+ static int is_globfunction (jl_value_t * v , jl_datatype_t * dv , jl_sym_t * * globname_out )
645
+ {
646
+ jl_sym_t * globname = dv -> name -> mt != NULL ? dv -> name -> mt -> name : NULL ;
647
+ * globname_out = globname ;
648
+ if (globname && !strchr (jl_symbol_name (globname ), '#' ) && !strchr (jl_symbol_name (globname ), '@' )) {
649
+ return 1 ;
650
+ }
651
+ return 0 ;
646
652
}
647
653
648
654
static size_t jl_static_show_x_sym_escaped (JL_STREAM * out , jl_sym_t * name ) JL_NOTSAFEPOINT
@@ -773,7 +779,7 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt
773
779
// `Base.Set{Int}`, and function types are printed as e.g. `typeof(Main.f)`
774
780
jl_datatype_t * dv = (jl_datatype_t * )v ;
775
781
jl_sym_t * globname ;
776
- int globfunc = is_globfunction (v , dv , & globname );
782
+ int globfunc = is_globname_binding ( v , dv ) && is_globfunction (v , dv , & globname );
777
783
jl_sym_t * sym = globfunc ? globname : dv -> name -> name ;
778
784
char * sn = jl_symbol_name (sym );
779
785
size_t quote = 0 ;
@@ -1065,20 +1071,18 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt
1065
1071
n += jl_static_show_x (out , * (jl_value_t * * )v , depth );
1066
1072
n += jl_printf (out , ")" );
1067
1073
}
1068
- else if (jl_static_is_function_ (vt )) {
1074
+ else if (jl_static_is_function_ (vt ) && is_globname_binding ( v , ( jl_datatype_t * ) vt ) ) {
1069
1075
// v is function instance (an instance of a Function type).
1070
1076
jl_datatype_t * dv = (jl_datatype_t * )vt ;
1071
- jl_sym_t * sym = dv -> name -> mt -> name ;
1072
- char * sn = jl_symbol_name (sym );
1073
-
1074
- jl_sym_t * globname ;
1075
- int globfunc = is_globfunction (v , dv , & globname );
1077
+ jl_sym_t * sym ;
1078
+ int globfunc = is_globfunction (v , dv , & sym );
1076
1079
int quote = 0 ;
1077
1080
if (jl_core_module && (dv -> name -> module != jl_core_module || !jl_module_exports_p (jl_core_module , sym ))) {
1078
1081
n += jl_static_show_x (out , (jl_value_t * )dv -> name -> module , depth );
1079
1082
n += jl_printf (out , "." );
1080
1083
1081
1084
size_t i = 0 ;
1085
+ char * sn = jl_symbol_name (sym );
1082
1086
if (globfunc && !jl_id_start_char (u8_nextchar (sn , & i ))) {
1083
1087
n += jl_printf (out , ":(" );
1084
1088
quote = 1 ;
0 commit comments