web-platform-tests / wpt.fyi

web-platform-tests dashboard
https://wpt.fyi/
Other
189 stars 90 forks source link

Cannot easily merge multiple queries #3588

Open gsnedders opened 1 year ago

gsnedders commented 1 year ago

Given a number of different search queries on wpt.fyi, you might think you could merge them with something like:

const merged = queries.map((q) => `exists(${q})`).join(" or ");

However, this doesn't actually work in some cases:

Using the same example as in #3587:

path:/css/css-display and exists(display contents)

is valid, but:

exists(path:/css/css-display and exists(display contents))

is invalid.

It's unclear to me why this doesn't parse, and Ohm doesn't give helpful error messages.

Trying to look through the parser, it may be that we don't allow nested exists?

gsnedders commented 1 year ago

In fact we sometimes seem to parse nested exists… in very unexpected ways!

The (horrible!) query: exists(path:/css/css-contain/container-queries and exists(path:/css/css-contain/container-queries/at-container-style-parsing.html or path:/css/css-contain/container-queries/at-container-style-serialization.html or path:/css/css-contain/container-queries/custom-property-style-queries.html or path:/css/css-contain/container-queries/custom-property-style-query-change.html or path:/css/css-contain/container-queries/display-contents-dynamic-style-queries.html or path:/css/css-contain/container-queries/nested-size-style-container-invalidation.html or path:/css/css-contain/container-queries/query-evaluation-style.html or path:/css/css-contain/container-queries/style-container-invalidation-inheritance.html or path:/css/css-contain/container-queries/style-container-for-shadow-dom.html or path:/css/css-contain/container-queries/style-query-with-unknown-width.html))

Parses as:

{
    "run_ids": [
        5130502731726848,
        5127139076079616,
        5170202456621056,
        5079107785719808
    ],
    "query": {
        "exists": [
            {
                "and": [
                    {
                        "path": "/css/css-contain/container-queries"
                    },
                    {
                        "pattern": "exists"
                    }
                ]
            },
            {
                "or": [
                    {
                        "path": "/css/css-contain/container-queries/at-container-style-parsing.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/at-container-style-serialization.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/custom-property-style-queries.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/custom-property-style-query-change.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/display-contents-dynamic-style-queries.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/nested-size-style-container-invalidation.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/query-evaluation-style.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/style-container-invalidation-inheritance.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/style-container-for-shadow-dom.html"
                    },
                    {
                        "path": "/css/css-contain/container-queries/style-query-with-unknown-width.html"
                    }
                ]
            }
        ]
    }
}