Where "not in" with empty slice

Is the following behavior expected?

Non-empty slice

{{- $pages := where site.RegularPages "Lang" "not in" (slice "fr") -}}
{{ printf "#%v" $pages }} --> Pages(1)

Empty slice

{{- $pages := where site.RegularPages "Lang" "not in" (slice) -}}
{{ printf "#%v" $pages }} --> Pages(0)

Demo: GitHub - AlanBreck/hugo-testing at not-in-behavior

The actual scenario is that I have a JSON data file which can potentially be an empty array. I would have expected both of the above examples to result in 1 page since the page language is not found in an empty slice.

If this is multilingual site, then this doesn’t make any sense.

where site.RegularPages "Lang" "not in" (slice "fr")

site.RegularPages refers to the current site (language). Conceptually its easier to think of projects and sites. A monolingual project has one site. A multilingual project has two or more sites.

If you want to access all pages across all sites, use site.AllPages.

Understood. Primarily asking about the behavior of the not in operator. The same behavior can be observed if checking Kind:

Non-empty slice

{{- $pages := where site.RegularPages "Kind" "not in" (slice "section") -}}
{{ printf "#%v" $pages }} --> Pages(1)

Empty slice

{{- $pages := where site.RegularPages "Kind" "not in" (slice) -}}
{{ printf "#%v" $pages }} --> Pages(0)

Noting that collections.In with an empty slice yields (to my mind) the expected behavior:

{{ printf "%#v" (not (in $forbiddenFruits "pineapple")) }} --> true
{{ printf "%#v" (not (in $forbiddenFruits "apple")) }} --> false
{{ printf "%#v" (not (in slice "pineapple")) }} --> true 

I agree with you.

content/
├── posts/
│   ├── _index.md
│   └── post-1.md
└── _index.md
{{ $p := where site.RegularPages "Kind" "not in" slice }}
{{ $p.Len | warnf "%#[2]v (%[2]T) [%[1]d]" math.Counter  }} → 0 (expected 1) 

{{ $n := not (in (slice) "a") }}
{{ $n | warnf "%#[2]v (%[2]T) [%[1]d]" math.Counter }} → true (expected true)

Go ahead a log an issue and reference this topic.

Submitted here: Unexpected behavior of "where ... not in" with empty slice · Issue #13621 · gohugoio/hugo · GitHub

Thanks!