Skip to content

Formatting fails with binary pattern match macro #357

@eproxus

Description

@eproxus

When formatting a module containing a macro with an argument that is put inside a binary, a compilation error is generated:

-module(my_module).

-export([func/2]).

-define(BIN(Arg), <<Arg>>).

func(uuid, ?BIN(A:8)) -> A.

Running rebar3 fmt on this file generates the following error:

$ rebar3 fmt src/my_module.erl
===> Analyzing applications...
===> Compiling erlfmt
src/my_module.erl:7:18: syntax error before: ':'

Erlang / Rebar 3 itself can compile the file just fine:

$ rebar3 shell
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling my_app
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Eshell V15.0.1 (press Ctrl+G to abort, type help(). for help)
1> my_module:func(<<"A">>).
65

erlfmt version: 1.3.0 and latest main
Erlang/OTP: 27.0.1
Rebar 3: 3.23.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions