diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result
index 194807290a07e4abb875de57a4f05ad35462da2d..479b74b69e45bfc56ee2755f92e17a21b8a181bf 100644
--- a/mysql-test/main/brackets.result
+++ b/mysql-test/main/brackets.result
@@ -207,4 +207,16 @@ a	b
 1	100
 3	30
 drop table t1;
+#
+# MDEV-16359: union with 3 selects in brackets
+#
+select 1 union select 1 union select 1;
+1
+1
+(select 1 union select 1 union select 1);
+1
+1
+((select 1) union (select 1) union (select 1));
+1
+1
 # End of 10.4 tests
diff --git a/mysql-test/main/brackets.test b/mysql-test/main/brackets.test
index ac22770ffc2aff8a7d7dd6412e902dfa32b825c2..699c70a900f05b20c16144ef80a36b9de3584102 100644
--- a/mysql-test/main/brackets.test
+++ b/mysql-test/main/brackets.test
@@ -80,5 +80,13 @@ select a,b from t1 order by 1 limit 3;
 
 drop table t1;
 
+--echo #
+--echo # MDEV-16359: union with 3 selects in brackets
+--echo #
+
+select 1 union select 1 union select 1;
+(select 1 union select 1 union select 1);
+((select 1) union (select 1) union (select 1));
+
 --echo # End of 10.4 tests
 
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index fa8155507f8b3d0c633f488dfe26204c2cb6051b..20b1eb413cfd48213d98d1fcc9265f7107ef8db6 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -8763,7 +8763,6 @@ void st_select_lex_unit::reset_distinct()
     if (sl->distinct)
     {
       union_distinct= sl;
-      return;
     }
   }
 }