Fixed a very nasty deadlock
All checks were successful
Rust / build (push) Successful in 3m34s

This commit is contained in:
2026-01-22 20:56:02 +01:00
parent f38193edcc
commit b9f1bb74d7
21 changed files with 506 additions and 355 deletions

View File

@@ -13,7 +13,7 @@ use futures::{AsyncRead, AsyncWrite, FutureExt, StreamExt, stream};
use orchid_api_derive::Coding;
use orchid_api_traits::{Coding, Decode, Encode, Request, enc_vec};
use orchid_base::error::{OrcErrv, OrcRes, mk_errv, mk_errv_floating};
use orchid_base::format::{FmtCtx, FmtUnit, Format, fmt};
use orchid_base::format::{FmtCtx, FmtUnit, Format, fmt, take_first};
use orchid_base::interner::is;
use orchid_base::location::Pos;
use orchid_base::name::Sym;
@@ -320,12 +320,18 @@ impl Format for AtomFactory {
}
}
pub async fn err_not_callable() -> OrcErrv {
mk_errv_floating(is("This atom is not callable").await, "Attempted to apply value as function")
pub async fn err_not_callable(unit: &FmtUnit) -> OrcErrv {
mk_errv_floating(
is("This atom is not callable").await,
format!("Attempted to apply {} as function", take_first(unit, false)),
)
}
pub async fn err_not_command() -> OrcErrv {
mk_errv_floating(is("This atom is not a command").await, "Settled on an inactionable value")
pub async fn err_not_command(unit: &FmtUnit) -> OrcErrv {
mk_errv_floating(
is("This atom is not a command").await,
format!("Settled on {} which is an inactionable value", take_first(unit, false)),
)
}
/// Read the type ID prefix from an atom, return type information and the rest

View File

@@ -228,7 +228,7 @@ pub trait OwnedAtom: Atomic<Variant = OwnedVariant> + Any + Clone + 'static {
fn val(&self) -> impl Future<Output = Cow<'_, Self::Data>>;
#[allow(unused_variables)]
fn call_ref(&self, arg: Expr) -> impl Future<Output = GExpr> {
async move { bot(err_not_callable().await) }
async move { bot(err_not_callable(&self.dyn_print().await).await) }
}
fn call(self, arg: Expr) -> impl Future<Output = GExpr> {
async {
@@ -239,7 +239,7 @@ pub trait OwnedAtom: Atomic<Variant = OwnedVariant> + Any + Clone + 'static {
}
#[allow(unused_variables)]
fn command(self) -> impl Future<Output = OrcRes<Option<GExpr>>> {
async move { Err(err_not_command().await) }
async move { Err(err_not_command(&self.dyn_print().await).await) }
}
#[allow(unused_variables)]
fn free(self) -> impl Future<Output = ()> { async {} }

View File

@@ -99,11 +99,11 @@ pub trait ThinAtom:
{
#[allow(unused_variables)]
fn call(&self, arg: Expr) -> impl Future<Output = GExpr> {
async move { bot(err_not_callable().await) }
async move { bot(err_not_callable(&self.print().await).await) }
}
#[allow(unused_variables)]
fn command(&self) -> impl Future<Output = OrcRes<Option<GExpr>>> {
async move { Err(err_not_command().await) }
async move { Err(err_not_command(&self.print().await).await) }
}
#[allow(unused_variables)]
fn print(&self) -> impl Future<Output = FmtUnit> {

View File

@@ -4,12 +4,13 @@ use std::pin::Pin;
use dyn_clone::DynClone;
use never::Never;
use orchid_base::error::{OrcErrv, OrcRes, mk_errv};
use orchid_base::format::{Format, fmt};
use orchid_base::interner::is;
use orchid_base::location::Pos;
use trait_set::trait_set;
use crate::atom::{AtomicFeatures, ForeignAtom, TAtom, ToAtom};
use crate::expr::Expr;
use crate::expr::{Expr, ExprKind};
use crate::gen_expr::{GExpr, atom, bot};
pub trait TryFromExpr: Sized {
@@ -26,14 +27,17 @@ impl<T: TryFromExpr, U: TryFromExpr> TryFromExpr for (T, U) {
}
}
async fn err_not_atom(pos: Pos) -> OrcErrv {
mk_errv(is("Expected an atom").await, "This expression is not an atom", [pos])
async fn err_not_atom(pos: Pos, value: &impl Format) -> OrcErrv {
mk_errv(is("Expected an atom").await, format!("{} is not an atom", fmt(value).await), [pos])
}
impl TryFromExpr for ForeignAtom {
async fn try_from_expr(expr: Expr) -> OrcRes<Self> {
match expr.atom().await {
Err(ex) => Err(err_not_atom(ex.data().await.pos.clone()).await),
if let ExprKind::Bottom(err) = &expr.data().await.kind {
return Err(err.clone());
}
match expr.clone().atom().await {
Err(ex) => Err(err_not_atom(ex.data().await.pos.clone(), &expr).await),
Ok(f) => Ok(f),
}
}