@@ -925,14 +925,29 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val
925925 }
926926 else if (head == jl_export_sym || head == jl_public_sym ) {
927927 int exp = (head == jl_export_sym );
928- for (size_t i = 0 ; i < jl_array_nrows (ex -> args ); i ++ ) {
929- jl_sym_t * name = (jl_sym_t * )jl_array_ptr_ref (ex -> args , i );
930- if (!jl_is_symbol (name ))
931- jl_eval_errorf (m , * toplevel_filename , * toplevel_lineno ,
932- exp ? "syntax: malformed \"export\" statement" :
933- "syntax: malformed \"public\" statement" );
934- jl_module_public (m , name , exp );
928+ volatile int any_new = 0 ;
929+ JL_LOCK (& world_counter_lock );
930+ size_t new_world = jl_atomic_load_acquire (& jl_world_counter )+ 1 ;
931+ JL_TRY {
932+ for (size_t i = 0 ; i < jl_array_nrows (ex -> args ); i ++ ) {
933+ jl_sym_t * name = (jl_sym_t * )jl_array_ptr_ref (ex -> args , i );
934+ if (!jl_is_symbol (name ))
935+ jl_eval_errorf (m , * toplevel_filename , * toplevel_lineno ,
936+ exp ? "syntax: malformed \"export\" statement" :
937+ "syntax: malformed \"public\" statement" );
938+ if (jl_module_public_ (m , name , exp , new_world ))
939+ any_new = 1 ;
940+ }
941+ }
942+ JL_CATCH {
943+ if (any_new )
944+ jl_atomic_store_release (& jl_world_counter , new_world );
945+ JL_UNLOCK (& world_counter_lock );
946+ jl_rethrow ();
935947 }
948+ if (any_new )
949+ jl_atomic_store_release (& jl_world_counter , new_world );
950+ JL_UNLOCK (& world_counter_lock );
936951 JL_GC_POP ();
937952 return jl_nothing ;
938953 }
0 commit comments