How to enable maybe_expr?

Hello everyone,

I’m trying enable maybe feature on my project, but always get the error:

{features_not_allowed, [maybe_expr,maybe_expr]}

I’m using rebar3 and OTP 25.1.2 in my project and tried some things to enable the feature.

I tried to add in rebar.config:

{erl_opts, [debug_info, 
            {parse_transform, lager_transform},
            {feature, maybe_expr, enable}]}.

and add in my_module.erl:

-feature(maybe_expr, enable).
-compile({feature, maybe_expr, enable}).

and add in vm.args:

-enable-feature maybe_expr

But I’but I was not successful with any option. To start I just run rebar2 shell on the project.

Thanks!

2 Likes

I usually do it that way, but you need to set the path to vm.args when calling rebar3 commands.
So, if vm.args is at config/vm.args (relative to current directory), you can run it with: env ERL_FLAGS="-args_file config/vm.args" rebar3 <command> ... (assuming you’re using some linux, not sure this would work on Windows)

2 Likes

Hello!

Does it interact with {relx,[{release,..,[{vm_args,...}]}]} in any way?

Or is it (as I understand)

  • ERL_FLAGS="-args_file config/vm.args" rebar3 ... dev-only (compile, dialyzer, eunit, etc)
  • {relx,...,{vm_args,...}} production-only (release)?

EDIT: is there any way to force this config in some project-local configuration file? I understand you can’t set it from within rebar.config, because it needs to set a flag on BEAM itself, which is already running when processing rebar.config.

1 Like

AFAIK no.
Note that starting from OTP 26.0 you don’t need to explicitly enable feature in the runtime via vm.args, it is enough to enable it in the compiler

2 Likes

Yes. Additionally, starting from OTP-27 will be default on (“Approved”) and starting from OTP-29 will be always-on (“Permanent”).

My problem is

> pkg info erlang
erlang-25.3.1,4

and FreeBSD being slowly moving target.

I just globally added '-enable-feature maybe_expr' to ERL_FLAGS. I hope it won’t cause any hiccups.

Thank you for your time.

2 Likes