Skip to main content

L1337 - Native Record in Guard

Error

-module(main).
-export([f/1]).
-record(#point {x, y}).
f(V) when #point{x = V, y = V} =:= V -> ok.
%% ^^^^^^^^^^^^^^^^^^^^ error: creating a record in a guard is only supported for tuple records

Explanation

The error occurs when a native record (EEP-79) is created inside a guard.

Creating a record in a guard expression is only supported for tuple records. Native records cannot be constructed in guards. To fix the error, build the record in the function body instead of the guard.