@@ -493,11 +493,14 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo)
493493 int last_in = ptls -> in_pure_callback ;
494494 jl_module_t * last_m = ptls -> current_module ;
495495 jl_module_t * task_last_m = ptls -> current_task -> current_module ;
496+ size_t last_age = jl_get_ptls_states ()-> world_age ;
496497 assert (jl_svec_len (linfo -> def -> sparam_syms ) == jl_svec_len (sparam_vals ));
497498 JL_TRY {
498499 ptls -> in_pure_callback = 1 ;
499500 // need to eval macros in the right module
500501 ptls -> current_task -> current_module = ptls -> current_module = linfo -> def -> module ;
502+ // and the right world
503+ ptls -> world_age = generator -> def -> min_world ;
501504
502505 ex = jl_exprn (lambda_sym , 2 );
503506
@@ -518,7 +521,6 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo)
518521 // invoke code generator
519522 assert (jl_nparams (tt ) == jl_array_len (argnames ) ||
520523 (linfo -> def -> isva && (jl_nparams (tt ) >= jl_array_len (argnames ) - 1 )));
521- // TODO: set world to that of the generator while calling func
522524 jl_array_ptr_set (body -> args , 1 ,
523525 jl_call_staged (sparam_vals , generator , jl_svec_data (tt -> parameters ), jl_nparams (tt )));
524526
@@ -545,6 +547,7 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo)
545547 jl_lineno = last_lineno ;
546548 ptls -> current_module = last_m ;
547549 ptls -> current_task -> current_module = task_last_m ;
550+ ptls -> world_age = last_age ;
548551 }
549552 JL_CATCH {
550553 ptls -> in_pure_callback = last_in ;
0 commit comments