Add extra test case to check behaviour of alernative patterns that use clause guards with vars
@@ -1713,6 +1713,7 @@ test() ->
"#,
);
+ // Alternative patterns with a clause containing vars
assert_erl!(
r#"
pub fn test() {
@@ -1736,6 +1737,33 @@ test() ->
"#,
);
+ // Alternative patterns with a guard clause containing vars
+ assert_erl!(
+ r#"
+pub fn test() {
+ let duplicate_name = 1
+
+ case 1 {
+ 1 | 2 if duplicate_name == 1 -> duplicate_name
+ }
+}"#,
+ r#"-module(the_app).
+-compile(no_auto_import).
+
+-export([test/0]).
+
+test() ->
+ DuplicateName = 1,
+ case 1 of
+ 1 when DuplicateName =:= 1 ->
+ DuplicateName;
+
+ 2 when DuplicateName =:= 1 ->
+ DuplicateName
+ end.
+"#,
+ );
+
assert_erl!(
r#"
pub const constant = Ok(1)
