[erlang-bugs] Match error when mapping a list of maps with anonymous functions in the shell

Anthony Ramine n.oxyde@REDACTED
Sun May 4 15:11:01 CEST 2014


No, augmented patterns require forbidding something currently allowed, namely:

	X = 1,
	fun (<<Y:X>>, X) -> {X,Y} end.

Currently, this is compiled to:

	X = 1,
	fun (<<Y:X>>, X2) -> {X2,Y} end.

But the new patterns would allow this, without an outer X:

	fun (<<Y:X>>, X) -> {X,Y} end.

Where the X bit size is taken from the X argument.

Given the ambiguity when a name is bound prior to the fun and both used and shadowed in the fun head itself, I think such confusing cases should be forbidden too.

My opinion is that we should forbid everything where a single variable name has multiple states. So in compound expressions, forbid any case where a variable is both bound (or exported) and unsafe. In fun heads, forbid any case where a variable is both used and shadowed.

-- 
Anthony Ramine

Le 4 mai 2014 à 14:43, Fred Hebert <mononcqc@REDACTED> a écrit :

> (Incidentally, I wonder if the changes to pattern matching
> recommended/planned for maps that would start allowing these use cases
> also.)




More information about the erlang-bugs mailing list