diff --git a/CHANGELOG.md b/CHANGELOG.md index ddea6c5ac..d99423243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - ESP32: fix i2c_driver_acquire and i2c_driver_release functions, that were working only once. +- Sending messages to registered processes using the `!` operator now works. ## [0.6.0-beta.0] - 2024-02-08 diff --git a/src/libAtomVM/opcodesswitch.h b/src/libAtomVM/opcodesswitch.h index b27df2be3..170303121 100644 --- a/src/libAtomVM/opcodesswitch.h +++ b/src/libAtomVM/opcodesswitch.h @@ -2213,7 +2213,16 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb) #endif #ifdef IMPL_EXECUTE_LOOP - int local_process_id = term_to_local_process_id(x_regs[0]); + term process_term = x_regs[0]; + int local_process_id; + if (term_is_atom(process_term)) { + local_process_id = globalcontext_get_registered_process(ctx->global, term_to_atom_index(process_term)); + if (UNLIKELY(local_process_id == 0 )){ + RAISE_ERROR(BADARG_ATOM); + } + } else { + local_process_id = term_to_local_process_id(process_term); + } TRACE("send/0 target_pid=%i\n", local_process_id); TRACE_SEND(ctx, x_regs[0], x_regs[1]); globalcontext_send_message(ctx->global, local_process_id, x_regs[1]);