Index: /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java	(revision 18290)
+++ /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java	(revision 18291)
@@ -2129,5 +2129,5 @@
             if (!tokenizer.readIfEqual(Token.RIGHT_PARENT))
                 throw new SearchParseError(Token.RIGHT_PARENT, tokenizer.nextToken());
-            return expression;
+            return expression != null ? expression : Always.INSTANCE;
         } else if (tokenizer.readIfEqual(Token.NOT)) {
             return new Not(parseFactor(tr("Missing operator for NOT")));
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java	(revision 18290)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java	(revision 18291)
@@ -841,3 +841,13 @@
         assertThrows(SearchParseError.class, () -> SearchCompiler.compile(searchString));
     }
+
+    /**
+     * Non-regression test for JOSM #21463
+     */
+    @Test
+    void testNonRegression21463() throws SearchParseError {
+        final SearchCompiler.Match c = SearchCompiler.compile("foo () () () bar");
+        assertTrue(c.match(OsmUtils.createPrimitive("node foo=bar")));
+        assertFalse(c.match(OsmUtils.createPrimitive("node name=bar")));
+    }
 }
