Skip to main content

L1338 - Native Record Multi-Field Initialization

Error

-module(main).
-export([f/0]).
-record(#point {x, y}).
f() -> #point{_ = 0}.
%% ^ error: multi-field initialization (assigning to _) is only supported for tuple records

Explanation

The error occurs when the _ = Expr multi-field initializer is used to create a native record (EEP-79).

The "initialize all omitted fields" syntax (#rec{_ = Expr}) is only supported for tuple records. For native records every field must be given a value individually. To fix the error, initialize each field explicitly.