Skip to main content

L1339 - Native Record Field Types

Error

-module(main).
-export_type([t/0]).
-record(#xy {x, y}).
-type t() :: #xy{x :: integer()}.
%% ^^^^^^^^^^^^ error: native records do not allow special field types

Explanation

The error occurs when a type definition tries to restrict the field types of a native record (EEP-79).

Unlike tuple records, native records do not allow a type to override the field types on a per-field basis (e.g. #xy{x :: integer()}), because it greatly complicates type checkers. Only the plain #xy{} form is allowed in a type.