Skip to content

Commit 1dde6e1

Browse files
committed
retain compatibility with code that assumes importall Base.Operators, but
give warnings
1 parent 3bb7e2f commit 1dde6e1

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

base/sparse/cholmod.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module CHOLMOD
44

55
import Base: (*), convert, copy, eltype, getindex, show, showarray, size,
6-
linearindexing, LinearFast, LinearSlow
6+
linearindexing, LinearFast, LinearSlow, ctranspose
77

88
import Base.LinAlg: (\), A_mul_Bc, A_mul_Bt, Ac_ldiv_B, Ac_mul_B, At_ldiv_B, At_mul_B,
99
cholfact, det, diag, ishermitian, isposdef,

src/dump.c

+2
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ static void jl_serialize_module(ios_t *s, jl_module_t *m)
540540
}
541541
jl_serialize_value(s, m->constant_table);
542542
write_uint8(s, m->istopmod);
543+
write_uint8(s, m->std_imports);
543544
write_uint64(s, m->uuid);
544545
}
545546

@@ -1336,6 +1337,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
13361337
m->constant_table = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&m->constant_table);
13371338
if (m->constant_table != NULL) jl_gc_wb(m, m->constant_table);
13381339
m->istopmod = read_uint8(s);
1340+
m->std_imports = read_uint8(s);
13391341
m->uuid = read_uint64(s);
13401342
return (jl_value_t*)m;
13411343
}

src/julia.h

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ typedef struct _jl_module_t {
312312
jl_array_t *constant_table;
313313
jl_function_t *call_func; // cached lookup of `call` within this module
314314
uint8_t istopmod;
315+
uint8_t std_imports; // only for temporarily deprecating `importall Base.Operators`
315316
uint64_t uuid;
316317
} jl_module_t;
317318

src/module.c

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jl_module_t *jl_new_module(jl_sym_t *name)
2828
m->constant_table = NULL;
2929
m->call_func = NULL;
3030
m->istopmod = 0;
31+
m->std_imports = 0;
3132
m->uuid = uv_now(uv_default_loop());
3233
htable_new(&m->bindings, 0);
3334
arraylist_new(&m->usings, 0);
@@ -120,6 +121,16 @@ DLLEXPORT jl_module_t *jl_get_module_of_binding(jl_module_t *m, jl_sym_t *var)
120121
// and overwriting.
121122
DLLEXPORT jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m, jl_sym_t *var)
122123
{
124+
if (jl_base_module && m->std_imports && !jl_binding_resolved_p(m,var)) {
125+
jl_module_t *opmod = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("Operators"));
126+
if (opmod != NULL && jl_defines_or_exports_p(opmod, var)) {
127+
jl_printf(JL_STDERR,
128+
"WARNING: module %s should explicitly import %s from %s\n",
129+
m->name->name, var->name, jl_base_module->name->name);
130+
jl_module_import(m, opmod, var);
131+
}
132+
}
133+
123134
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
124135
jl_binding_t *b = *bp;
125136

@@ -133,6 +144,15 @@ DLLEXPORT jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m, jl_sym_t *
133144
jl_errorf("error in method definition: %s.%s cannot be extended", b->owner->name->name, var->name);
134145
}
135146
else {
147+
if (jl_base_module && b->owner == jl_base_module) {
148+
jl_module_t *opmod = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("Operators"));
149+
if (opmod != NULL && jl_defines_or_exports_p(opmod, var)) {
150+
jl_printf(JL_STDERR,
151+
"WARNING: module %s should explicitly import %s from %s\n",
152+
m->name->name, var->name, b->owner->name->name);
153+
return b2;
154+
}
155+
}
136156
jl_errorf("error in method definition: function %s.%s must be explicitly imported to be extended", b->owner->name->name, var->name);
137157
}
138158
}

src/toplevel.c

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void jl_add_standard_imports(jl_module_t *m)
4242
jl_module_using(m, jl_base_module);
4343
// import Base.call
4444
jl_module_import(m, jl_base_module, jl_symbol("call"));
45+
m->std_imports = 1;
4546
}
4647

4748
jl_module_t *jl_new_main_module(void)

0 commit comments

Comments
 (0)