Skip to content

Commit 01c8202

Browse files
committed
Do not allow protocols to define structs nor exceptions, closes #14158
1 parent 194ecfd commit 01c8202

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/elixir/lib/protocol.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,15 @@ defmodule Protocol do
758758

759759
# We don't allow function definition inside protocols
760760
import Kernel,
761-
except: [def: 1, def: 2, defdelegate: 2, defguard: 1, defguardp: 1]
761+
except: [
762+
def: 1,
763+
def: 2,
764+
defdelegate: 2,
765+
defguard: 1,
766+
defguardp: 1,
767+
defstruct: 1,
768+
defexception: 1
769+
]
762770

763771
# Import the new `def` that is used by protocols
764772
import Protocol, only: [def: 1]

0 commit comments

Comments
 (0)