Bug report after update to v5x

I noticed that code which had been working for a long time stopped functioning after updating to version 5.0.1.
It works correctly in version 4.3.17.
I created a test project as an example; you can take a look at it.

DTOs

public class Category1Info
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public class Category2Info
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public class ProductInfo
{
    public int Category1 { get; set; }
    public int Category2 { get; set; }
    public string Name { get; set; }
    public List<string> Colors { get; set; } = [];
}

DefaultViewModel.cs

public class DefaultViewModel : MasterPageViewModel
{
    public List<ProductInfo> Products { get; set; }

    public List<Category1Info> Categories1 { get; set; }
    public List<Category2Info> Categories2 { get; set; }

    public DefaultViewModel()
    {

    }

    public override async Task Load()
    {
        if (!Context.IsPostBack)
        {
            Categories1 =
            [
                new() { Id = 1, Name = "C1-1" },
                new() { Id = 2, Name = "C1-2" },
                new() { Id = 3, Name = "C1-3" }
            ];

            Categories2 =
            [
                new() { Id = 10, Name = "C2-10" },
                new() { Id = 11, Name = "C2-11" },
                new() { Id = 12, Name = "C2-12" }
            ];

            Products =
            [
                new() { Name = "Product 1", Category1 = 1, Category2 = 10, Colors = ["Red"] },
                new() { Name = "Product 2", Category1 = 2, Category2 = 11, Colors = ["Green", "Yellow"] },
                new() { Name = "Product 3", Category1 = 3, Category2 = 12, Colors = ["Orange"] }
            ];
        }

        await base.Load();
    }

}

Default.dothtml

@viewModel DotvvmApplication1.ViewModels.DefaultViewModel, DotvvmApplication1
@masterPage Views/MasterPage.dotmaster
<dot:Content ContentPlaceHolderID="MainContent">
    <table border="1">
        <thead>
            <tr>
                <th></th>
                <dot:Repeater DataSource="{value: _root.Categories1}" RenderWrapperTag="false">
                    <th>{{value: Name}}</th>
                </dot:Repeater>
            </tr>
        </thead>
        <tbody>
            <dot:Repeater DataSource="{value: _root.Categories2}" RenderWrapperTag="false">
                <tr>
                    <th>
                        {{value: Name}}
                    </th>
                    <dot:Repeater DataSource="{value: _root.Categories1}" RenderWrapperTag="false">
                        <td>

                            <dot:Repeater DataSource="{value: _root.Products.FirstOrDefault(x => x.Category1 == _this.Id && x.Category2 == _parent.Id).Colors}"
                                          RenderWrapperTag="false">
                                <ItemTemplate>
                                    {{value: _this}}
                                </ItemTemplate>
                                <SeparatorTemplate>
                                    ,
                                </SeparatorTemplate>
                            </dot:Repeater>
                        </td>
                    </dot:Repeater>
                </tr>
            </dot:Repeater>
        </tbody>
    </table>
</dot:Content>

v4.3.17 :white_check_mark:

v5x :cross_mark:

Uncaught TypeError: Unable to process binding "template: function(){return { foreach:Categories2,name:"j2AN3jFFJJra3mH1+4t7bgvcgox0TNtvd9HrwOPf+Bg="} }"
Message: Unable to process binding "template: function(){return { foreach:$parent.Categories1,name:"SWfhroGYkcVLAM3Th5gv2Fe8JHE/y7xFKxH4dnGZqNY="} }"
Message: Unable to process binding "template: function(){return { foreach:$parents[1].Products()?.find((x) => ko.unwrap(x).Category1() == Id() && ko.unwrap(x).Category2() == $parent.Id())()?.Colors,name:"WCyHKNTyHWi0zmm4cP/xF1ot+hUXoeVQSfQO9ZB3rMs=",separatorTemplate:"yUtsycAMplDRuAJkWHWZIr0gZBB9cBFTgoXieKvdvpI="} }"
Message: $parents[1].Products(...)?.find(...) is not a function
at template (eval at createBindingsStringEvaluator (knockout:3248:16), :3:191)
at evaluateValueAccessor (knockout:3521:16)
at knockout:3698:32
at init (knockout:6166:58)
at knockout:3757:46
at Object.ignore (knockout:1618:33)
at knockout:3756:48
at Object.arrayForEach (knockout:205:24)
at applyBindingsToNodeInternal (knockout:3742:22)
at applyBindingsToNodeAndDescendantsInternal (knockout:3600:44)

The problematic code is this:

_root.Products.FirstOrDefault(x => x.Category1 == _this.Id && x.Category2 == _parent.Id).Colors

i

DefaultViewModel.cs (1.3 KB)

Default.dothtml (1.5 KB)

ProductInfo.cs (487 Bytes)

if i change code to

.FirstOrDefault(x => x.Category1 == _this.Id ).Colors

The code is logically incorrect :), but no error occurs.

I think && x.Category2 == _parent.Id throws an error.