Proposal: automatically highlight diff in ex_unit when match operator is used

31 views
Skip to first unread message

Artur Plysyuk

unread,
Nov 3, 2021, 8:25:34 AM11/3/21
to elixir-lang-core
Hi,

Current behavour:

[]  = all_enqueued(queue: :default)
#  raises ** (MatchError)

assert []  = all_enqueued(queue: :default)
# formatted as match (=) failed

Actually, the proposal is to kinda implicitly add assert to expressions which have match operator, so in case of errors output is automatically formatted like the expression is written with assert.

José Valim

unread,
Nov 3, 2021, 9:08:03 AM11/3/21
to elixir-l...@googlegroups.com
I would prefer to not change the semantics of the code, because it can lead to subtle behavior: for example, what if the match is inside one of the monad libraries that already override what = means?

You can say we could detect those cases, but it is not trivial to differentiate from a macro that transform = from another one that wouldn’t (such as the if/2) macro.

In other words, macros that traverse ASTs and change the semantics of the code should not be encouraged, so I don’t think we should go ahead with this.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/133cd523-bdbf-4544-a524-671219707aean%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages