From 9ec401cbda1515acc5b24e5c08d7ab7c17cb8ace Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Thu, 3 Jul 2025 00:22:11 +0200 Subject: [PATCH] Do not require BadStructError struct at build time BadStructError is not available with Elixir >= v1.19, so do not use it at build time, recent Elixir environments do not have it. Signed-off-by: Davide Bettio --- libs/exavmlib/lib/ErlangError.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/exavmlib/lib/ErlangError.ex b/libs/exavmlib/lib/ErlangError.ex index fe6edba7e..3102b6f13 100644 --- a/libs/exavmlib/lib/ErlangError.ex +++ b/libs/exavmlib/lib/ErlangError.ex @@ -22,6 +22,7 @@ defmodule ErlangError do # This avoids crashing the compiler at build time @compile {:autoload, false} + @compile {:no_warn_undefined, BadStructError} defexception [:original] @@ -56,7 +57,9 @@ defmodule ErlangError do end def normalize({:badstruct, struct, term}, _stacktrace) do - %BadStructError{struct: struct, term: term} + # starting from v1.19.0, BadStructError is not available + # still older Elixir versions might need it + BadStructError.__struct__(%{struct: struct, term: term}) end def normalize({:badmatch, term}, _stacktrace) do