Skip to main content

L1324 - Match Alias with Constructors on Both Sides

Warning

foo({a, B} = {Y, Z}) -> {B, Y, Z}.
%% ^ warning: a pattern `P1=P2` where both sides are constructors

Explanation

A pattern P1=P2 where both sides are constructors (e.g., tuples, lists, maps) requires the compiler to unify the two sides, which can be arbitrarily complex. This feature is rarely used in practice.

%% Instead of:
foo({a, B} = {Y, Z}) -> {B, Y, Z}.

%% Write:
foo({a = Y, B = Z}) -> {B, Y, Z}.

This warning can be suppressed with -compile(nowarn_match_alias_pats).