From 01c82022f215630a9c4ee4a6e6e2526445b51a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 9 Jan 2025 09:18:54 +0100 Subject: [PATCH] Do not allow protocols to define structs nor exceptions, closes #14158 --- lib/elixir/lib/protocol.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/elixir/lib/protocol.ex b/lib/elixir/lib/protocol.ex index 7952b8d0fd..1e4c3911ad 100644 --- a/lib/elixir/lib/protocol.ex +++ b/lib/elixir/lib/protocol.ex @@ -758,7 +758,15 @@ defmodule Protocol do # We don't allow function definition inside protocols import Kernel, - except: [def: 1, def: 2, defdelegate: 2, defguard: 1, defguardp: 1] + except: [ + def: 1, + def: 2, + defdelegate: 2, + defguard: 1, + defguardp: 1, + defstruct: 1, + defexception: 1 + ] # Import the new `def` that is used by protocols import Protocol, only: [def: 1]