Skip to content

Commit

Permalink
Do not allow protocols to define structs nor exceptions, closes #14158
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 9, 2025
1 parent 194ecfd commit 01c8202
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/elixir/lib/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 01c8202

Please sign in to comment.