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