// Copyright 2020 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "src/tint/lang/wgsl/resolver/resolver.h"

#include <tuple>

#include "gmock/gmock.h"
#include "src/tint/lang/core/address_space.h"
#include "src/tint/lang/core/builtin_value.h"
#include "src/tint/lang/core/type/reference.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/assignment_statement.h"
#include "src/tint/lang/wgsl/ast/break_statement.h"
#include "src/tint/lang/wgsl/ast/builtin_texture_helper_test.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/continue_statement.h"
#include "src/tint/lang/wgsl/ast/float_literal_expression.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/if_statement.h"
#include "src/tint/lang/wgsl/ast/loop_statement.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/switch_statement.h"
#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/ast/workgroup_attribute.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/lang/wgsl/sem/array.h"
#include "src/tint/lang/wgsl/sem/call.h"
#include "src/tint/lang/wgsl/sem/function.h"
#include "src/tint/lang/wgsl/sem/member_accessor_expression.h"
#include "src/tint/lang/wgsl/sem/module.h"
#include "src/tint/lang/wgsl/sem/statement.h"
#include "src/tint/lang/wgsl/sem/switch_statement.h"
#include "src/tint/lang/wgsl/sem/variable.h"
#include "src/tint/utils/text/string_stream.h"

namespace tint::resolver {
namespace {

using ::testing::ElementsAre;
using ::testing::HasSubstr;

using namespace tint::core::fluent_types;     // NOLINT
using namespace tint::core::number_suffixes;  // NOLINT

// Helpers and typedefs
template <typename T>
using DataType = builder::DataType<T>;
template <typename T, int ID = 0>
using alias = builder::alias<T, ID>;
template <typename T>
using alias1 = builder::alias1<T>;
template <typename T>
using alias2 = builder::alias2<T>;
template <typename T>
using alias3 = builder::alias3<T>;
using Op = core::BinaryOp;

TEST_F(ResolverTest, Stmt_Assign) {
    auto* v = Var("v", ty.f32());
    auto* lhs = Expr("v");
    auto* rhs = Expr(2.3_f);

    auto* assign = Assign(lhs, rhs);
    WrapInFunction(v, assign);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(lhs), nullptr);
    ASSERT_NE(TypeOf(rhs), nullptr);

    EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(rhs)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(lhs), assign);
    EXPECT_EQ(StmtOf(rhs), assign);
}

TEST_F(ResolverTest, Stmt_Case) {
    auto* v = Var("v", ty.f32());
    auto* lhs = Expr("v");
    auto* rhs = Expr(2.3_f);

    auto* assign = Assign(lhs, rhs);
    auto* block = Block(assign);
    auto* sel = CaseSelector(3_i);
    auto* cse = Case(sel, block);
    auto* def = DefaultCase();
    auto* cond_var = Var("c", ty.i32());
    auto* sw = Switch(cond_var, cse, def);
    WrapInFunction(v, cond_var, sw);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(lhs), nullptr);
    ASSERT_NE(TypeOf(rhs), nullptr);
    EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(rhs)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(lhs), assign);
    EXPECT_EQ(StmtOf(rhs), assign);
    EXPECT_EQ(BlockOf(assign), block);
    auto* sem = Sem().Get(sw);
    ASSERT_EQ(sem->Cases().size(), 2u);
    EXPECT_EQ(sem->Cases()[0]->Declaration(), cse);
    ASSERT_EQ(sem->Cases()[0]->Selectors().size(), 1u);
    EXPECT_EQ(sem->Cases()[1]->Selectors().size(), 1u);
}

TEST_F(ResolverTest, Stmt_Case_AddressOf_Invalid) {
    auto* cond_var = Var("i", ty.i32());
    WrapInFunction(cond_var, Switch("i", Case(CaseSelector(AddressOf(1_a)), Block())));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "error: cannot take the address of value of type 'abstract-int'");
}

TEST_F(ResolverTest, Stmt_Block) {
    auto* v = Var("v", ty.f32());
    auto* lhs = Expr("v");
    auto* rhs = Expr(2.3_f);

    auto* assign = Assign(lhs, rhs);
    auto* block = Block(assign);
    WrapInFunction(v, block);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(lhs), nullptr);
    ASSERT_NE(TypeOf(rhs), nullptr);
    EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(rhs)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(lhs), assign);
    EXPECT_EQ(StmtOf(rhs), assign);
    EXPECT_EQ(BlockOf(lhs), block);
    EXPECT_EQ(BlockOf(rhs), block);
    EXPECT_EQ(BlockOf(assign), block);
}

TEST_F(ResolverTest, Stmt_If) {
    auto* v = Var("v", ty.f32());
    auto* else_lhs = Expr("v");
    auto* else_rhs = Expr(2.3_f);

    auto* else_body = Block(Assign(else_lhs, else_rhs));

    auto* else_cond = Expr(true);
    auto* else_stmt = If(else_cond, else_body);

    auto* lhs = Expr("v");
    auto* rhs = Expr(2.3_f);

    auto* assign = Assign(lhs, rhs);
    auto* body = Block(assign);
    auto* cond = Expr(true);
    auto* stmt = If(cond, body, Else(else_stmt));
    WrapInFunction(v, stmt);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(stmt->condition), nullptr);
    ASSERT_NE(TypeOf(else_lhs), nullptr);
    ASSERT_NE(TypeOf(else_rhs), nullptr);
    ASSERT_NE(TypeOf(lhs), nullptr);
    ASSERT_NE(TypeOf(rhs), nullptr);
    EXPECT_TRUE(TypeOf(stmt->condition)->Is<core::type::Bool>());
    EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(else_rhs)->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(rhs)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(lhs), assign);
    EXPECT_EQ(StmtOf(rhs), assign);
    EXPECT_EQ(StmtOf(cond), stmt);
    EXPECT_EQ(StmtOf(else_cond), else_stmt);
    EXPECT_EQ(BlockOf(lhs), body);
    EXPECT_EQ(BlockOf(rhs), body);
    EXPECT_EQ(BlockOf(else_lhs), else_body);
    EXPECT_EQ(BlockOf(else_rhs), else_body);
}

TEST_F(ResolverTest, Stmt_Loop) {
    auto* v = Var("v", ty.f32());
    auto* body_lhs = Expr("v");
    auto* body_rhs = Expr(2.3_f);

    auto* body = Block(Assign(body_lhs, body_rhs), Break());
    auto* continuing_lhs = Expr("v");
    auto* continuing_rhs = Expr(2.3_f);

    auto* break_if = BreakIf(false);
    auto* continuing = Block(Assign(continuing_lhs, continuing_rhs), break_if);
    auto* stmt = Loop(body, continuing);
    WrapInFunction(v, stmt);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(body_lhs), nullptr);
    ASSERT_NE(TypeOf(body_rhs), nullptr);
    ASSERT_NE(TypeOf(continuing_lhs), nullptr);
    ASSERT_NE(TypeOf(continuing_rhs), nullptr);
    EXPECT_TRUE(TypeOf(body_lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(body_rhs)->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(continuing_rhs)->Is<core::type::F32>());
    EXPECT_EQ(BlockOf(body_lhs), body);
    EXPECT_EQ(BlockOf(body_rhs), body);
    EXPECT_EQ(BlockOf(continuing_lhs), continuing);
    EXPECT_EQ(BlockOf(continuing_rhs), continuing);
    EXPECT_EQ(BlockOf(break_if), continuing);
}

TEST_F(ResolverTest, Stmt_Return) {
    auto* cond = Expr(2_i);

    auto* ret = Return(cond);
    Func("test", tint::Empty, ty.i32(), Vector{ret}, tint::Empty);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(cond), nullptr);
    EXPECT_TRUE(TypeOf(cond)->Is<core::type::I32>());
}

TEST_F(ResolverTest, Stmt_Return_WithoutValue) {
    auto* ret = Return();
    WrapInFunction(ret);

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, Stmt_Switch) {
    auto* v = Var("v", ty.f32());
    auto* lhs = Expr("v");
    auto* rhs = Expr(2.3_f);
    auto* case_block = Block(Assign(lhs, rhs));
    auto* stmt = Switch(Expr(2_i), Case(CaseSelector(3_i), case_block), DefaultCase());
    WrapInFunction(v, stmt);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(stmt->condition), nullptr);
    ASSERT_NE(TypeOf(lhs), nullptr);
    ASSERT_NE(TypeOf(rhs), nullptr);

    EXPECT_TRUE(TypeOf(stmt->condition)->Is<core::type::I32>());
    EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_TRUE(TypeOf(rhs)->Is<core::type::F32>());
    EXPECT_EQ(BlockOf(lhs), case_block);
    EXPECT_EQ(BlockOf(rhs), case_block);
}

TEST_F(ResolverTest, Stmt_Call) {
    Func("my_func", tint::Empty, ty.void_(),
         Vector{
             Return(),
         });

    auto* expr = Call("my_func");

    auto* call = CallStmt(expr);
    WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(expr), nullptr);
    EXPECT_TRUE(TypeOf(expr)->Is<core::type::Void>());
    EXPECT_EQ(StmtOf(expr), call);
}

TEST_F(ResolverTest, Stmt_VariableDecl) {
    auto* var = Var("my_var", ty.i32(), Expr(2_i));
    auto* init = var->initializer;

    auto* decl = Decl(var);
    WrapInFunction(decl);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(init), nullptr);
    EXPECT_TRUE(TypeOf(init)->Is<core::type::I32>());
}

TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
    auto* my_int = Alias("MyInt", ty.i32());
    auto* var = Var("my_var", ty.Of(my_int), Expr(2_i));
    auto* init = var->initializer;

    auto* decl = Decl(var);
    WrapInFunction(decl);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(init), nullptr);
    EXPECT_TRUE(TypeOf(init)->Is<core::type::I32>());
}

TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
    auto* init = Expr(2_i);
    GlobalVar("my_var", ty.i32(), core::AddressSpace::kPrivate, init);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(init), nullptr);
    EXPECT_TRUE(TypeOf(init)->Is<core::type::I32>());
    EXPECT_EQ(StmtOf(init), nullptr);
}

TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
    // fn func_i32() {
    //   {
    //     var foo : i32 = 2;
    //     var bar : i32 = foo;
    //   }
    //   var foo : f32 = 2.0;
    //   var bar : f32 = foo;
    // }

    // Declare i32 "foo" inside a block
    auto* foo_i32 = Var("foo", ty.i32(), Expr(2_i));
    auto* foo_i32_init = foo_i32->initializer;
    auto* foo_i32_decl = Decl(foo_i32);

    // Reference "foo" inside the block
    auto* bar_i32 = Var("bar", ty.i32(), Expr("foo"));
    auto* bar_i32_init = bar_i32->initializer;
    auto* bar_i32_decl = Decl(bar_i32);

    auto* inner = Block(foo_i32_decl, bar_i32_decl);

    // Declare f32 "foo" at function scope
    auto* foo_f32 = Var("foo", ty.f32(), Expr(2_f));
    auto* foo_f32_init = foo_f32->initializer;
    auto* foo_f32_decl = Decl(foo_f32);

    // Reference "foo" at function scope
    auto* bar_f32 = Var("bar", ty.f32(), Expr("foo"));
    auto* bar_f32_init = bar_f32->initializer;
    auto* bar_f32_decl = Decl(bar_f32);

    Func("func", tint::Empty, ty.void_(), Vector{inner, foo_f32_decl, bar_f32_decl});

    EXPECT_TRUE(r()->Resolve()) << r()->error();
    ASSERT_NE(TypeOf(foo_i32_init), nullptr);
    EXPECT_TRUE(TypeOf(foo_i32_init)->Is<core::type::I32>());
    ASSERT_NE(TypeOf(foo_f32_init), nullptr);
    EXPECT_TRUE(TypeOf(foo_f32_init)->Is<core::type::F32>());
    ASSERT_NE(TypeOf(bar_i32_init), nullptr);
    EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapRef()->Is<core::type::I32>());
    ASSERT_NE(TypeOf(bar_f32_init), nullptr);
    EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(foo_i32_init), foo_i32_decl);
    EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
    EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
    EXPECT_EQ(StmtOf(bar_f32_init), bar_f32_decl);
    EXPECT_TRUE(CheckVarUsers(foo_i32, Vector{bar_i32->initializer}));
    EXPECT_TRUE(CheckVarUsers(foo_f32, Vector{bar_f32->initializer}));
    ASSERT_NE(VarOf(bar_i32->initializer), nullptr);
    EXPECT_EQ(VarOf(bar_i32->initializer)->Declaration(), foo_i32);
    ASSERT_NE(VarOf(bar_f32->initializer), nullptr);
    EXPECT_EQ(VarOf(bar_f32->initializer)->Declaration(), foo_f32);
}

TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
    // fn func_i32() {
    //   var foo : i32 = 2;
    // }
    // var foo : f32 = 2.0;
    // fn func_f32() {
    //   var bar : f32 = foo;
    // }

    // Declare i32 "foo" inside a function
    auto* fn_i32 = Var("foo", ty.i32(), Expr(2_i));
    auto* fn_i32_init = fn_i32->initializer;
    auto* fn_i32_decl = Decl(fn_i32);
    Func("func_i32", tint::Empty, ty.void_(), Vector{fn_i32_decl});

    // Declare f32 "foo" at module scope
    auto* mod_f32 = Var("foo", ty.f32(), core::AddressSpace::kPrivate, Expr(2_f));
    auto* mod_init = mod_f32->initializer;
    AST().AddGlobalVariable(mod_f32);

    // Reference "foo" in another function
    auto* fn_f32 = Var("bar", ty.f32(), Expr("foo"));
    auto* fn_f32_init = fn_f32->initializer;
    auto* fn_f32_decl = Decl(fn_f32);
    Func("func_f32", tint::Empty, ty.void_(), Vector{fn_f32_decl});

    EXPECT_TRUE(r()->Resolve()) << r()->error();
    ASSERT_NE(TypeOf(mod_init), nullptr);
    EXPECT_TRUE(TypeOf(mod_init)->Is<core::type::F32>());
    ASSERT_NE(TypeOf(fn_i32_init), nullptr);
    EXPECT_TRUE(TypeOf(fn_i32_init)->Is<core::type::I32>());
    ASSERT_NE(TypeOf(fn_f32_init), nullptr);
    EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(fn_i32_init), fn_i32_decl);
    EXPECT_EQ(StmtOf(mod_init), nullptr);
    EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
    EXPECT_TRUE(CheckVarUsers(fn_i32, tint::Empty));
    EXPECT_TRUE(CheckVarUsers(mod_f32, Vector{fn_f32->initializer}));
    ASSERT_NE(VarOf(fn_f32->initializer), nullptr);
    EXPECT_EQ(VarOf(fn_f32->initializer)->Declaration(), mod_f32);
}

TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
    // var<private> a : array<f32, 10u>;
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_u)), core::AddressSpace::kPrivate);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    EXPECT_EQ(ary->Count(), create<core::type::ConstantArrayCount>(10u));
}

TEST_F(ResolverTest, ArraySize_SignedLiteral) {
    // var<private> a : array<f32, 10i>;
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_i)), core::AddressSpace::kPrivate);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    EXPECT_EQ(ary->Count(), create<core::type::ConstantArrayCount>(10u));
}

TEST_F(ResolverTest, ArraySize_UnsignedConst) {
    // const size = 10u;
    // var<private> a : array<f32, size>;
    GlobalConst("size", Expr(10_u));
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), core::AddressSpace::kPrivate);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    EXPECT_EQ(ary->Count(), create<core::type::ConstantArrayCount>(10u));
}

TEST_F(ResolverTest, ArraySize_SignedConst) {
    // const size = 0;
    // var<private> a : array<f32, size>;
    GlobalConst("size", Expr(10_i));
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), core::AddressSpace::kPrivate);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    EXPECT_EQ(ary->Count(), create<core::type::ConstantArrayCount>(10u));
}

TEST_F(ResolverTest, ArraySize_NamedOverride) {
    // override size = 10i;
    // var<workgroup> a : array<f32, size>;
    auto* override = Override("size", Expr(10_i));
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), core::AddressSpace::kWorkgroup);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    auto* sem_override = Sem().Get(override);
    ASSERT_NE(sem_override, nullptr);
    EXPECT_EQ(ary->Count(), create<sem::NamedOverrideArrayCount>(sem_override));
}

TEST_F(ResolverTest, ArraySize_NamedOverride_Equivalence) {
    // override size = 10i;
    // var<workgroup> a : array<f32, size>;
    // var<workgroup> b : array<f32, size>;
    auto* override = Override("size", Expr(10_i));
    auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), core::AddressSpace::kWorkgroup);
    auto* b = GlobalVar("b", ty.array(ty.f32(), Expr("size")), core::AddressSpace::kWorkgroup);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref_a = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref_a, nullptr);
    auto* ary_a = ref_a->StoreType()->As<sem::Array>();

    ASSERT_NE(TypeOf(b), nullptr);
    auto* ref_b = TypeOf(b)->As<core::type::Reference>();
    ASSERT_NE(ref_b, nullptr);
    auto* ary_b = ref_b->StoreType()->As<sem::Array>();

    auto* sem_override = Sem().Get(override);
    ASSERT_NE(sem_override, nullptr);
    EXPECT_EQ(ary_a->Count(), create<sem::NamedOverrideArrayCount>(sem_override));
    EXPECT_EQ(ary_b->Count(), create<sem::NamedOverrideArrayCount>(sem_override));
    EXPECT_EQ(ary_a, ary_b);
}

TEST_F(ResolverTest, ArraySize_UnnamedOverride) {
    // override size = 10i;
    // var<workgroup> a : array<f32, size*2>;
    auto* override = Override("size", Expr(10_i));
    auto* cnt = Mul("size", 2_a);
    auto* a = GlobalVar("a", ty.array(ty.f32(), cnt), core::AddressSpace::kWorkgroup);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref, nullptr);
    auto* ary = ref->StoreType()->As<sem::Array>();
    auto* sem_override = Sem().Get(override);
    ASSERT_NE(sem_override, nullptr);
    EXPECT_EQ(ary->Count(), create<sem::UnnamedOverrideArrayCount>(Sem().Get(cnt)));
}

TEST_F(ResolverTest, ArraySize_UnamedOverride_Equivalence) {
    // override size = 10i;
    // var<workgroup> a : array<f32, size>;
    // var<workgroup> b : array<f32, size>;
    auto* override = Override("size", Expr(10_i));
    auto* a_cnt = Mul("size", 2_a);
    auto* b_cnt = Mul("size", 2_a);
    auto* a = GlobalVar("a", ty.array(ty.f32(), a_cnt), core::AddressSpace::kWorkgroup);
    auto* b = GlobalVar("b", ty.array(ty.f32(), b_cnt), core::AddressSpace::kWorkgroup);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(a), nullptr);
    auto* ref_a = TypeOf(a)->As<core::type::Reference>();
    ASSERT_NE(ref_a, nullptr);
    auto* ary_a = ref_a->StoreType()->As<sem::Array>();

    ASSERT_NE(TypeOf(b), nullptr);
    auto* ref_b = TypeOf(b)->As<core::type::Reference>();
    ASSERT_NE(ref_b, nullptr);
    auto* ary_b = ref_b->StoreType()->As<sem::Array>();

    auto* sem_override = Sem().Get(override);
    ASSERT_NE(sem_override, nullptr);
    EXPECT_EQ(ary_a->Count(), create<sem::UnnamedOverrideArrayCount>(Sem().Get(a_cnt)));
    EXPECT_EQ(ary_b->Count(), create<sem::UnnamedOverrideArrayCount>(Sem().Get(b_cnt)));
    EXPECT_NE(ary_a, ary_b);
}

TEST_F(ResolverTest, Expr_Bitcast) {
    GlobalVar("name", ty.f32(), core::AddressSpace::kPrivate);

    auto* bitcast = Bitcast<f32>(Expr("name"));
    WrapInFunction(bitcast);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(bitcast), nullptr);
    EXPECT_TRUE(TypeOf(bitcast)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Call) {
    Func("my_func", tint::Empty, ty.f32(), Vector{Return(0_f)});

    auto* call = Call("my_func");
    WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(call), nullptr);
    EXPECT_TRUE(TypeOf(call)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
    Func("func", tint::Empty, ty.f32(), Vector{Return(0_f)});

    auto* expr = Add(Call("func"), Call("func"));
    WrapInFunction(expr);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(expr), nullptr);
    EXPECT_TRUE(TypeOf(expr)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Call_WithParams) {
    Func("my_func", Vector{Param(Sym(), ty.f32())}, ty.f32(),
         Vector{
             Return(1.2_f),
         });

    auto* param = Expr(2.4_f);

    auto* call = Call("my_func", param);
    WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(param), nullptr);
    EXPECT_TRUE(TypeOf(param)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Call_Builtin) {
    auto* call = Call("round", 2.4_f);
    WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(call), nullptr);
    EXPECT_TRUE(TypeOf(call)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Cast) {
    GlobalVar("name", ty.f32(), core::AddressSpace::kPrivate);

    auto* cast = Call<f32>("name");
    WrapInFunction(cast);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(cast), nullptr);
    EXPECT_TRUE(TypeOf(cast)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Initializer_Scalar) {
    auto* s = Expr(1_f);
    WrapInFunction(s);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(s), nullptr);
    EXPECT_TRUE(TypeOf(s)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) {
    auto* tc = Call<vec2<f32>>(1_f, 1_f);
    WrapInFunction(tc);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(tc), nullptr);
    ASSERT_TRUE(TypeOf(tc)->Is<core::type::Vector>());
    EXPECT_TRUE(TypeOf(tc)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    EXPECT_EQ(TypeOf(tc)->As<core::type::Vector>()->Width(), 2u);
}

TEST_F(ResolverTest, Expr_Initializer_Type_Vec3) {
    auto* tc = Call<vec3<f32>>(1_f, 1_f, 1_f);
    WrapInFunction(tc);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(tc), nullptr);
    ASSERT_TRUE(TypeOf(tc)->Is<core::type::Vector>());
    EXPECT_TRUE(TypeOf(tc)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    EXPECT_EQ(TypeOf(tc)->As<core::type::Vector>()->Width(), 3u);
}

TEST_F(ResolverTest, Expr_Initializer_Type_Vec4) {
    auto* tc = Call<vec4<f32>>(1_f, 1_f, 1_f, 1_f);
    WrapInFunction(tc);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(tc), nullptr);
    ASSERT_TRUE(TypeOf(tc)->Is<core::type::Vector>());
    EXPECT_TRUE(TypeOf(tc)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    EXPECT_EQ(TypeOf(tc)->As<core::type::Vector>()->Width(), 4u);
}

TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) {
    auto* my_var = GlobalVar("my_var", ty.f32(), core::AddressSpace::kPrivate);

    auto* ident = Expr("my_var");
    WrapInFunction(ident);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(ident), nullptr);
    EXPECT_TRUE(TypeOf(ident)->Is<core::type::F32>());
    EXPECT_TRUE(CheckVarUsers(my_var, Vector{ident}));
    ASSERT_NE(VarOf(ident), nullptr);
    EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
}

TEST_F(ResolverTest, Expr_Identifier_GlobalConst) {
    auto* my_var = GlobalConst("my_var", ty.f32(), Call<f32>());

    auto* ident = Expr("my_var");
    WrapInFunction(ident);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(ident), nullptr);
    EXPECT_TRUE(TypeOf(ident)->Is<core::type::F32>());
    EXPECT_TRUE(CheckVarUsers(my_var, Vector{ident}));
    ASSERT_NE(VarOf(ident), nullptr);
    EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
}

TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) {
    auto* my_var_a = Expr("my_var");
    auto* var = Let("my_var", ty.f32(), Call<f32>());
    auto* decl = Decl(Var("b", ty.f32(), my_var_a));

    Func("my_func", tint::Empty, ty.void_(),
         Vector{
             Decl(var),
             decl,
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(my_var_a), nullptr);
    EXPECT_TRUE(TypeOf(my_var_a)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(my_var_a), decl);
    EXPECT_TRUE(CheckVarUsers(var, Vector{my_var_a}));
    ASSERT_NE(VarOf(my_var_a), nullptr);
    EXPECT_EQ(VarOf(my_var_a)->Declaration(), var);
}

TEST_F(ResolverTest, IndexAccessor_Dynamic_Ref_F32) {
    // var a : array<bool, 10u> = 0;
    // var idx : f32 = f32();
    // var f : f32 = a[idx];
    auto* a = Var("a", ty.array<bool, 10>(), Call<array<bool, 10>>());
    auto* idx = Var("idx", ty.f32(), Call<f32>());
    auto* f = Var("f", ty.f32(), IndexAccessor("a", Expr(Source{{12, 34}}, idx)));
    Func("my_func", tint::Empty, ty.void_(),
         Vector{
             Decl(a),
             Decl(idx),
             Decl(f),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: index must be of type 'i32' or 'u32', found: 'f32'");
}

TEST_F(ResolverTest, Expr_Identifier_FunctionVariable) {
    auto* my_var_a = Expr("my_var");
    auto* my_var_b = Expr("my_var");
    auto* assign = Assign(my_var_a, my_var_b);

    auto* var = Var("my_var", ty.f32());

    Func("my_func", tint::Empty, ty.void_(),
         Vector{
             Decl(var),
             assign,
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(my_var_a), nullptr);
    ASSERT_TRUE(TypeOf(my_var_a)->Is<core::type::Reference>());
    EXPECT_TRUE(TypeOf(my_var_a)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(my_var_a), assign);
    ASSERT_NE(TypeOf(my_var_b), nullptr);
    EXPECT_TRUE(TypeOf(my_var_b)->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(my_var_b), assign);
    EXPECT_TRUE(CheckVarUsers(var, Vector{my_var_a, my_var_b}));
    ASSERT_NE(VarOf(my_var_a), nullptr);
    EXPECT_EQ(VarOf(my_var_a)->Declaration(), var);
    ASSERT_NE(VarOf(my_var_b), nullptr);
    EXPECT_EQ(VarOf(my_var_b)->Declaration(), var);
}

TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) {
    auto* v = Expr("v");
    auto* p = Expr("p");
    auto* v_decl = Decl(Var("v", ty.f32()));
    auto* p_decl = Decl(Let("p", ty.ptr<function, f32>(), AddressOf(v)));
    auto* assign = Assign(Deref(p), 1.23_f);
    Func("my_func", tint::Empty, ty.void_(),
         Vector{
             v_decl,
             p_decl,
             assign,
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(v), nullptr);
    ASSERT_TRUE(TypeOf(v)->Is<core::type::Reference>());
    EXPECT_TRUE(TypeOf(v)->UnwrapRef()->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(v), p_decl);
    ASSERT_NE(TypeOf(p), nullptr);
    ASSERT_TRUE(TypeOf(p)->Is<core::type::Pointer>());
    EXPECT_TRUE(TypeOf(p)->UnwrapPtr()->Is<core::type::F32>());
    EXPECT_EQ(StmtOf(p), assign);
}

TEST_F(ResolverTest, Expr_Call_Function) {
    Func("my_func", tint::Empty, ty.f32(),
         Vector{
             Return(0_f),
         });

    auto* call = Call("my_func");
    WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(call), nullptr);
    EXPECT_TRUE(TypeOf(call)->Is<core::type::F32>());
}

TEST_F(ResolverTest, Expr_Identifier_Unknown) {
    auto* a = Expr("a");
    WrapInFunction(a);

    EXPECT_FALSE(r()->Resolve());
}

TEST_F(ResolverTest, Function_Parameters) {
    auto* param_a = Param("a", ty.f32());
    auto* param_b = Param("b", ty.i32());
    auto* param_c = Param("c", ty.u32());

    auto* func = Func("my_func",
                      Vector{
                          param_a,
                          param_b,
                          param_c,
                      },
                      ty.void_(), tint::Empty);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);
    EXPECT_EQ(func_sem->Parameters().Length(), 3u);
    EXPECT_TRUE(func_sem->Parameters()[0]->Type()->Is<core::type::F32>());
    EXPECT_TRUE(func_sem->Parameters()[1]->Type()->Is<core::type::I32>());
    EXPECT_TRUE(func_sem->Parameters()[2]->Type()->Is<core::type::U32>());
    EXPECT_EQ(func_sem->Parameters()[0]->Declaration(), param_a);
    EXPECT_EQ(func_sem->Parameters()[1]->Declaration(), param_b);
    EXPECT_EQ(func_sem->Parameters()[2]->Declaration(), param_c);
    EXPECT_TRUE(func_sem->ReturnType()->Is<core::type::Void>());
}

TEST_F(ResolverTest, Function_Parameters_Locations) {
    auto* param_a = Param("a", ty.f32(), Vector{Location(3_a)});
    auto* param_b = Param("b", ty.u32(), Vector{Builtin(core::BuiltinValue::kVertexIndex)});
    auto* param_c = Param("c", ty.u32(), Vector{Location(1_a)});

    GlobalVar("my_vec", ty.vec4<f32>(), core::AddressSpace::kPrivate);
    auto* func = Func("my_func",
                      Vector{
                          param_a,
                          param_b,
                          param_c,
                      },
                      ty.vec4<f32>(),
                      Vector{
                          Return("my_vec"),
                      },
                      Vector{
                          Stage(ast::PipelineStage::kVertex),
                      },
                      Vector{
                          Builtin(core::BuiltinValue::kPosition),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);
    EXPECT_EQ(func_sem->Parameters().Length(), 3u);
    EXPECT_EQ(3u, func_sem->Parameters()[0]->Attributes().location);
    EXPECT_FALSE(func_sem->Parameters()[1]->Attributes().location.has_value());
    EXPECT_EQ(1u, func_sem->Parameters()[2]->Attributes().location);
}

TEST_F(ResolverTest, Function_GlobalVariable_Location) {
    auto* var =
        GlobalVar("my_vec", ty.vec4<f32>(), core::AddressSpace::kIn,
                  Vector{Location(3_a), Disable(ast::DisabledValidation::kIgnoreAddressSpace)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* sem = Sem().Get<sem::GlobalVariable>(var);
    ASSERT_NE(sem, nullptr);
    EXPECT_EQ(3u, sem->Attributes().location);
}

TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
    auto* s = Structure("S", Vector{Member("m", ty.u32())});

    auto* sb_var = GlobalVar("sb_var", ty.Of(s), core::AddressSpace::kStorage,
                             core::Access::kReadWrite, Binding(0_a), Group(0_a));
    auto* wg_var = GlobalVar("wg_var", ty.f32(), core::AddressSpace::kWorkgroup);
    auto* priv_var = GlobalVar("priv_var", ty.f32(), core::AddressSpace::kPrivate);

    auto* func = Func("my_func", tint::Empty, ty.void_(),
                      Vector{
                          Assign("wg_var", "wg_var"),
                          Assign("sb_var", "sb_var"),
                          Assign("priv_var", "priv_var"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);
    EXPECT_EQ(func_sem->Parameters().Length(), 0u);
    EXPECT_TRUE(func_sem->ReturnType()->Is<core::type::Void>());

    const auto& vars = func_sem->TransitivelyReferencedGlobals();
    ASSERT_EQ(vars.Length(), 3u);
    EXPECT_EQ(vars[0]->Declaration(), wg_var);
    EXPECT_EQ(vars[1]->Declaration(), sb_var);
    EXPECT_EQ(vars[2]->Declaration(), priv_var);
}

TEST_F(ResolverTest, Function_ReturnType_Location) {
    auto* func = Func("my_func", tint::Empty, ty.f32(),
                      Vector{
                          Return(1_f),
                      },
                      Vector{
                          Stage(ast::PipelineStage::kFragment),
                      },
                      Vector{
                          Location(2_a),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* sem = Sem().Get(func);
    ASSERT_NE(nullptr, sem);
    EXPECT_EQ(2u, sem->ReturnLocation());
}

TEST_F(ResolverTest, Function_ReturnType_NoLocation) {
    GlobalVar("my_vec", ty.vec4<f32>(), core::AddressSpace::kPrivate);
    auto* func = Func("my_func", tint::Empty, ty.vec4<f32>(),
                      Vector{
                          Return("my_vec"),
                      },
                      Vector{
                          Stage(ast::PipelineStage::kVertex),
                      },
                      Vector{
                          Builtin(core::BuiltinValue::kPosition),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* sem = Sem().Get(func);
    ASSERT_NE(nullptr, sem);
    EXPECT_FALSE(sem->ReturnLocation());
}

TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
    auto* s = Structure("S", Vector{Member("m", ty.u32())});

    auto* sb_var = GlobalVar("sb_var", ty.Of(s), core::AddressSpace::kStorage,
                             core::Access::kReadWrite, Binding(0_a), Group(0_a));
    auto* wg_var = GlobalVar("wg_var", ty.f32(), core::AddressSpace::kWorkgroup);
    auto* priv_var = GlobalVar("priv_var", ty.f32(), core::AddressSpace::kPrivate);

    Func("my_func", tint::Empty, ty.f32(),
         Vector{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"),
                Assign("priv_var", "priv_var"), Return(0_f)});

    auto* func2 = Func("func", tint::Empty, ty.void_(),
                       Vector{
                           WrapInStatement(Call("my_func")),
                       },
                       tint::Empty);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func2_sem = Sem().Get(func2);
    ASSERT_NE(func2_sem, nullptr);
    EXPECT_EQ(func2_sem->Parameters().Length(), 0u);

    const auto& vars = func2_sem->TransitivelyReferencedGlobals();
    ASSERT_EQ(vars.Length(), 3u);
    EXPECT_EQ(vars[0]->Declaration(), wg_var);
    EXPECT_EQ(vars[1]->Declaration(), sb_var);
    EXPECT_EQ(vars[2]->Declaration(), priv_var);
}

TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) {
    auto* func = Func("my_func", tint::Empty, ty.void_(),
                      Vector{
                          Decl(Var("var", ty.f32())),
                          Assign("var", 1_f),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
    EXPECT_TRUE(func_sem->ReturnType()->Is<core::type::Void>());
}

TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) {
    auto* func = Func("my_func", tint::Empty, ty.void_(),
                      Vector{
                          Decl(Let("var", ty.f32(), Call<f32>())),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
    EXPECT_TRUE(func_sem->ReturnType()->Is<core::type::Void>());
}

TEST_F(ResolverTest, Function_NotRegisterFunctionParams) {
    auto* func = Func("my_func", Vector{Param("var", ty.f32())}, ty.void_(), tint::Empty);
    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
    EXPECT_TRUE(func_sem->ReturnType()->Is<core::type::Void>());
}

TEST_F(ResolverTest, Function_CallSites) {
    auto* foo = Func("foo", tint::Empty, ty.void_(), tint::Empty);

    auto* call_1 = Call("foo");
    auto* call_2 = Call("foo");
    auto* bar = Func("bar", tint::Empty, ty.void_(),
                     Vector{
                         CallStmt(call_1),
                         CallStmt(call_2),
                     });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* foo_sem = Sem().Get(foo);
    ASSERT_NE(foo_sem, nullptr);
    ASSERT_EQ(foo_sem->CallSites().Length(), 2u);
    EXPECT_EQ(foo_sem->CallSites()[0]->Declaration(), call_1);
    EXPECT_EQ(foo_sem->CallSites()[1]->Declaration(), call_2);

    auto* bar_sem = Sem().Get(bar);
    ASSERT_NE(bar_sem, nullptr);
    EXPECT_EQ(bar_sem->CallSites().Length(), 0u);
}

TEST_F(ResolverTest, Function_WorkgroupSize_NotSet) {
    // @compute @workgroup_size(1)
    // fn main() {}
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], 1u);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], 1u);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], 1u);
}

TEST_F(ResolverTest, Function_WorkgroupSize_Literals) {
    // @compute @workgroup_size(8, 2, 3)
    // fn main() {}
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize(8_i, 2_i, 3_i),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], 8u);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], 2u);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], 3u);
}

TEST_F(ResolverTest, Function_WorkgroupSize_ViaConst) {
    // const width = 16i;
    // const height = 8i;
    // const depth = 2i;
    // @compute @workgroup_size(width, height, depth)
    // fn main() {}
    GlobalConst("width", ty.i32(), Expr(16_i));
    GlobalConst("height", ty.i32(), Expr(8_i));
    GlobalConst("depth", ty.i32(), Expr(2_i));
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize("width", "height", "depth"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], 16u);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], 8u);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], 2u);
}

TEST_F(ResolverTest, Function_WorkgroupSize_ViaConst_NestedInitializer) {
    // const width = i32(i32(i32(8i)));
    // const height = i32(i32(i32(4i)));
    // @compute @workgroup_size(width, height)
    // fn main() {}
    GlobalConst("width", ty.i32(), Call<i32>(Call<i32>(Call<i32>(8_i))));
    GlobalConst("height", ty.i32(), Call<i32>(Call<i32>(Call<i32>(4_i))));
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize("width", "height"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], 8u);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], 4u);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], 1u);
}

TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts) {
    // @id(0) override width = 16i;
    // @id(1) override height = 8i;
    // @id(2) override depth = 2i;
    // @compute @workgroup_size(width, height, depth)
    // fn main() {}
    Override("width", ty.i32(), Expr(16_i), Id(0_a));
    Override("height", ty.i32(), Expr(8_i), Id(1_a));
    Override("depth", ty.i32(), Expr(2_i), Id(2_a));
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize("width", "height", "depth"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], std::nullopt);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], std::nullopt);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], std::nullopt);
}

TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts_NoInit) {
    // @id(0) override width : i32;
    // @id(1) override height : i32;
    // @id(2) override depth : i32;
    // @compute @workgroup_size(width, height, depth)
    // fn main() {}
    Override("width", ty.i32(), Id(0_a));
    Override("height", ty.i32(), Id(1_a));
    Override("depth", ty.i32(), Id(2_a));
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize("width", "height", "depth"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], std::nullopt);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], std::nullopt);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], std::nullopt);
}

TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
    // @id(1) override height = 2i;
    // const depth = 3i;
    // @compute @workgroup_size(8, height, depth)
    // fn main() {}
    Override("height", ty.i32(), Expr(2_i), Id(0_a));
    GlobalConst("depth", ty.i32(), Expr(3_i));
    auto* func = Func("main", tint::Empty, ty.void_(), tint::Empty,
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize(8_i, "height", "depth"),
                      });

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* func_sem = Sem().Get(func);
    ASSERT_NE(func_sem, nullptr);

    EXPECT_EQ(func_sem->WorkgroupSize()[0], 8u);
    EXPECT_EQ(func_sem->WorkgroupSize()[1], std::nullopt);
    EXPECT_EQ(func_sem->WorkgroupSize()[2], 3u);
}

TEST_F(ResolverTest, Expr_MemberAccessor_Type) {
    auto* mem = MemberAccessor(Ident(Source{{12, 34}}, "f32"), "member");
    WrapInFunction(mem);

    EXPECT_FALSE(r()->Resolve()) << r()->error();
    EXPECT_EQ(r()->error(), R"(12:34 error: cannot use type 'f32' as value
12:34 note: are you missing '()'?)");
}

TEST_F(ResolverTest, Expr_MemberAccessor_NonCompoundType) {
    GlobalConst("depth", ty.i32(), Expr(3_i));
    auto* mem = MemberAccessor(Ident(Source{{12, 34}}, "depth"), "x");
    WrapInFunction(mem);

    EXPECT_FALSE(r()->Resolve()) << r()->error();
    EXPECT_EQ(r()->error(), R"(12:34 error: cannot index into expression of type 'i32')");
}

TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
    auto* st =
        Structure("S", Vector{Member("first_member", ty.i32()), Member("second_member", ty.f32())});
    GlobalVar("my_struct", ty.Of(st), core::AddressSpace::kPrivate);

    auto* mem = MemberAccessor("my_struct", "second_member");
    WrapInFunction(mem);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(mem), nullptr);
    EXPECT_TRUE(TypeOf(mem)->Is<core::type::F32>());
    auto* sma = Sem().Get(mem)->UnwrapLoad()->As<sem::StructMemberAccess>();
    ASSERT_NE(sma, nullptr);
    EXPECT_TRUE(sma->Member()->Type()->Is<core::type::F32>());
    EXPECT_EQ(sma->Object()->Declaration(), mem->object);
    EXPECT_EQ(sma->Member()->Index(), 1u);
    EXPECT_EQ(sma->Member()->Name().Name(), "second_member");
}

TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
    auto* st =
        Structure("S", Vector{Member("first_member", ty.i32()), Member("second_member", ty.f32())});
    auto* alias = Alias("alias", ty.Of(st));
    GlobalVar("my_struct", ty.Of(alias), core::AddressSpace::kPrivate);

    auto* mem = MemberAccessor("my_struct", "second_member");
    WrapInFunction(mem);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(mem), nullptr);
    EXPECT_TRUE(TypeOf(mem)->Is<core::type::F32>());
    auto* sma = Sem().Get(mem)->UnwrapLoad()->As<sem::StructMemberAccess>();
    ASSERT_NE(sma, nullptr);
    EXPECT_EQ(sma->Object()->Declaration(), mem->object);
    EXPECT_TRUE(sma->Member()->Type()->Is<core::type::F32>());
    EXPECT_EQ(sma->Member()->Index(), 1u);
}

TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) {
    GlobalVar("my_vec", ty.vec4<f32>(), core::AddressSpace::kPrivate);

    auto* mem = MemberAccessor("my_vec", "xzyw");
    WrapInFunction(mem);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(mem), nullptr);
    ASSERT_TRUE(TypeOf(mem)->Is<core::type::Vector>());
    EXPECT_TRUE(TypeOf(mem)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    EXPECT_EQ(TypeOf(mem)->As<core::type::Vector>()->Width(), 4u);
    auto* sma = Sem().Get(mem)->As<sem::Swizzle>();
    ASSERT_NE(sma, nullptr);
    EXPECT_EQ(sma->Object()->Declaration(), mem->object);
    EXPECT_THAT(sma->Indices(), ElementsAre(0, 2, 1, 3));
}

TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
    GlobalVar("my_vec", ty.vec3<f32>(), core::AddressSpace::kPrivate);

    auto* mem = MemberAccessor("my_vec", "b");
    WrapInFunction(mem);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(mem), nullptr);
    ASSERT_TRUE(TypeOf(mem)->Is<core::type::F32>());
    auto* sma = Sem().Get(mem)->UnwrapLoad()->As<sem::Swizzle>();
    ASSERT_NE(sma, nullptr);
    EXPECT_EQ(sma->Object()->Declaration(), mem->object);
    EXPECT_THAT(sma->Indices(), ElementsAre(2));
}

TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
    // struct b {
    //   vec4<f32> foo
    // }
    // struct A {
    //   array<b, 3u> mem
    // }
    // var c : A
    // c.mem[0].foo.yx
    //   -> vec2<f32>
    //
    // fn f() {
    //   c.mem[0].foo
    // }
    //

    auto* stB = Structure("B", Vector{Member("foo", ty.vec4<f32>())});
    auto* stA = Structure("A", Vector{Member("mem", ty.array(ty.Of(stB), 3_i))});
    GlobalVar("c", ty.Of(stA), core::AddressSpace::kPrivate);

    auto* mem =
        MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("c", "mem"), 0_i), "foo"), "yx");
    WrapInFunction(mem);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(mem), nullptr);
    ASSERT_TRUE(TypeOf(mem)->Is<core::type::Vector>());
    EXPECT_TRUE(TypeOf(mem)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    EXPECT_EQ(TypeOf(mem)->As<core::type::Vector>()->Width(), 2u);
    ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
}

TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) {
    auto* st =
        Structure("S", Vector{Member("first_member", ty.f32()), Member("second_member", ty.f32())});
    GlobalVar("my_struct", ty.Of(st), core::AddressSpace::kPrivate);

    auto* expr = Add(MemberAccessor("my_struct", "first_member"),
                     MemberAccessor("my_struct", "second_member"));
    WrapInFunction(expr);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(expr), nullptr);
    EXPECT_TRUE(TypeOf(expr)->Is<core::type::F32>());
}

namespace ExprBinaryTest {

template <typename T, int ID>
struct Aliased {
    using type = alias<T, ID>;
};

template <int N, typename T, int ID>
struct Aliased<vec<N, T>, ID> {
    using type = vec<N, alias<T, ID>>;
};

template <int N, int M, typename T, int ID>
struct Aliased<mat<N, M, T>, ID> {
    using type = mat<N, M, alias<T, ID>>;
};

struct Params {
    core::BinaryOp op;
    builder::ast_type_func_ptr create_lhs_type;
    builder::ast_type_func_ptr create_rhs_type;
    builder::ast_type_func_ptr create_lhs_alias_type;
    builder::ast_type_func_ptr create_rhs_alias_type;
    builder::sem_type_func_ptr create_result_type;
};

template <typename LHS, typename RHS, typename RES>
constexpr Params ParamsFor(core::BinaryOp op) {
    return Params{op,
                  DataType<LHS>::AST,
                  DataType<RHS>::AST,
                  DataType<typename Aliased<LHS, 0>::type>::AST,
                  DataType<typename Aliased<RHS, 1>::type>::AST,
                  DataType<RES>::Sem};
}

static constexpr core::BinaryOp all_ops[] = {
    core::BinaryOp::kAnd,
    core::BinaryOp::kOr,
    core::BinaryOp::kXor,
    core::BinaryOp::kLogicalAnd,
    core::BinaryOp::kLogicalOr,
    core::BinaryOp::kEqual,
    core::BinaryOp::kNotEqual,
    core::BinaryOp::kLessThan,
    core::BinaryOp::kGreaterThan,
    core::BinaryOp::kLessThanEqual,
    core::BinaryOp::kGreaterThanEqual,
    core::BinaryOp::kShiftLeft,
    core::BinaryOp::kShiftRight,
    core::BinaryOp::kAdd,
    core::BinaryOp::kSubtract,
    core::BinaryOp::kMultiply,
    core::BinaryOp::kDivide,
    core::BinaryOp::kModulo,
};

static constexpr builder::ast_type_func_ptr all_create_type_funcs[] = {
    DataType<bool>::AST,         //
    DataType<u32>::AST,          //
    DataType<i32>::AST,          //
    DataType<f32>::AST,          //
    DataType<vec3<bool>>::AST,   //
    DataType<vec3<i32>>::AST,    //
    DataType<vec3<u32>>::AST,    //
    DataType<vec3<f32>>::AST,    //
    DataType<mat3x3<f32>>::AST,  //
    DataType<mat2x3<f32>>::AST,  //
    DataType<mat3x2<f32>>::AST   //
};

// A list of all valid test cases for 'lhs op rhs', except that for vecN and
// matNxN, we only test N=3.
static constexpr Params all_valid_cases[] = {
    // Logical expressions
    // https://gpuweb.github.io/gpuweb/wgsl.html#logical-expr

    // Binary logical expressions
    ParamsFor<bool, bool, bool>(Op::kLogicalAnd),
    ParamsFor<bool, bool, bool>(Op::kLogicalOr),

    ParamsFor<bool, bool, bool>(Op::kAnd),
    ParamsFor<bool, bool, bool>(Op::kOr),
    ParamsFor<vec3<bool>, vec3<bool>, vec3<bool>>(Op::kAnd),
    ParamsFor<vec3<bool>, vec3<bool>, vec3<bool>>(Op::kOr),

    // Arithmetic expressions
    // https://gpuweb.github.io/gpuweb/wgsl.html#arithmetic-expr

    // Binary arithmetic expressions over scalars
    ParamsFor<i32, i32, i32>(Op::kAdd),
    ParamsFor<i32, i32, i32>(Op::kSubtract),
    ParamsFor<i32, i32, i32>(Op::kMultiply),
    ParamsFor<i32, i32, i32>(Op::kDivide),
    ParamsFor<i32, i32, i32>(Op::kModulo),

    ParamsFor<u32, u32, u32>(Op::kAdd),
    ParamsFor<u32, u32, u32>(Op::kSubtract),
    ParamsFor<u32, u32, u32>(Op::kMultiply),
    ParamsFor<u32, u32, u32>(Op::kDivide),
    ParamsFor<u32, u32, u32>(Op::kModulo),

    ParamsFor<f32, f32, f32>(Op::kAdd),
    ParamsFor<f32, f32, f32>(Op::kSubtract),
    ParamsFor<f32, f32, f32>(Op::kMultiply),
    ParamsFor<f32, f32, f32>(Op::kDivide),
    ParamsFor<f32, f32, f32>(Op::kModulo),

    // Binary arithmetic expressions over vectors
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kAdd),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kSubtract),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kMultiply),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kDivide),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kModulo),

    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kAdd),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kSubtract),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kMultiply),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kDivide),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kModulo),

    ParamsFor<vec3<f32>, vec3<f32>, vec3<f32>>(Op::kAdd),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<f32>>(Op::kSubtract),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<f32>>(Op::kMultiply),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<f32>>(Op::kDivide),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<f32>>(Op::kModulo),

    // Binary arithmetic expressions with mixed scalar and vector operands
    ParamsFor<vec3<i32>, i32, vec3<i32>>(Op::kAdd),
    ParamsFor<vec3<i32>, i32, vec3<i32>>(Op::kSubtract),
    ParamsFor<vec3<i32>, i32, vec3<i32>>(Op::kMultiply),
    ParamsFor<vec3<i32>, i32, vec3<i32>>(Op::kDivide),
    ParamsFor<vec3<i32>, i32, vec3<i32>>(Op::kModulo),

    ParamsFor<i32, vec3<i32>, vec3<i32>>(Op::kAdd),
    ParamsFor<i32, vec3<i32>, vec3<i32>>(Op::kSubtract),
    ParamsFor<i32, vec3<i32>, vec3<i32>>(Op::kMultiply),
    ParamsFor<i32, vec3<i32>, vec3<i32>>(Op::kDivide),
    ParamsFor<i32, vec3<i32>, vec3<i32>>(Op::kModulo),

    ParamsFor<vec3<u32>, u32, vec3<u32>>(Op::kAdd),
    ParamsFor<vec3<u32>, u32, vec3<u32>>(Op::kSubtract),
    ParamsFor<vec3<u32>, u32, vec3<u32>>(Op::kMultiply),
    ParamsFor<vec3<u32>, u32, vec3<u32>>(Op::kDivide),
    ParamsFor<vec3<u32>, u32, vec3<u32>>(Op::kModulo),

    ParamsFor<u32, vec3<u32>, vec3<u32>>(Op::kAdd),
    ParamsFor<u32, vec3<u32>, vec3<u32>>(Op::kSubtract),
    ParamsFor<u32, vec3<u32>, vec3<u32>>(Op::kMultiply),
    ParamsFor<u32, vec3<u32>, vec3<u32>>(Op::kDivide),
    ParamsFor<u32, vec3<u32>, vec3<u32>>(Op::kModulo),

    ParamsFor<vec3<f32>, f32, vec3<f32>>(Op::kAdd),
    ParamsFor<vec3<f32>, f32, vec3<f32>>(Op::kSubtract),
    ParamsFor<vec3<f32>, f32, vec3<f32>>(Op::kMultiply),
    ParamsFor<vec3<f32>, f32, vec3<f32>>(Op::kDivide),
    ParamsFor<vec3<f32>, f32, vec3<f32>>(Op::kModulo),

    ParamsFor<f32, vec3<f32>, vec3<f32>>(Op::kAdd),
    ParamsFor<f32, vec3<f32>, vec3<f32>>(Op::kSubtract),
    ParamsFor<f32, vec3<f32>, vec3<f32>>(Op::kMultiply),
    ParamsFor<f32, vec3<f32>, vec3<f32>>(Op::kDivide),
    ParamsFor<f32, vec3<f32>, vec3<f32>>(Op::kModulo),

    // Matrix arithmetic
    ParamsFor<mat2x3<f32>, f32, mat2x3<f32>>(Op::kMultiply),
    ParamsFor<mat3x2<f32>, f32, mat3x2<f32>>(Op::kMultiply),
    ParamsFor<mat3x3<f32>, f32, mat3x3<f32>>(Op::kMultiply),

    ParamsFor<f32, mat2x3<f32>, mat2x3<f32>>(Op::kMultiply),
    ParamsFor<f32, mat3x2<f32>, mat3x2<f32>>(Op::kMultiply),
    ParamsFor<f32, mat3x3<f32>, mat3x3<f32>>(Op::kMultiply),

    ParamsFor<vec3<f32>, mat2x3<f32>, vec2<f32>>(Op::kMultiply),
    ParamsFor<vec2<f32>, mat3x2<f32>, vec3<f32>>(Op::kMultiply),
    ParamsFor<vec3<f32>, mat3x3<f32>, vec3<f32>>(Op::kMultiply),

    ParamsFor<mat3x2<f32>, vec3<f32>, vec2<f32>>(Op::kMultiply),
    ParamsFor<mat2x3<f32>, vec2<f32>, vec3<f32>>(Op::kMultiply),
    ParamsFor<mat3x3<f32>, vec3<f32>, vec3<f32>>(Op::kMultiply),

    ParamsFor<mat2x3<f32>, mat3x2<f32>, mat3x3<f32>>(Op::kMultiply),
    ParamsFor<mat3x2<f32>, mat2x3<f32>, mat2x2<f32>>(Op::kMultiply),
    ParamsFor<mat3x2<f32>, mat3x3<f32>, mat3x2<f32>>(Op::kMultiply),
    ParamsFor<mat3x3<f32>, mat3x3<f32>, mat3x3<f32>>(Op::kMultiply),
    ParamsFor<mat3x3<f32>, mat2x3<f32>, mat2x3<f32>>(Op::kMultiply),

    ParamsFor<mat2x3<f32>, mat2x3<f32>, mat2x3<f32>>(Op::kAdd),
    ParamsFor<mat3x2<f32>, mat3x2<f32>, mat3x2<f32>>(Op::kAdd),
    ParamsFor<mat3x3<f32>, mat3x3<f32>, mat3x3<f32>>(Op::kAdd),

    ParamsFor<mat2x3<f32>, mat2x3<f32>, mat2x3<f32>>(Op::kSubtract),
    ParamsFor<mat3x2<f32>, mat3x2<f32>, mat3x2<f32>>(Op::kSubtract),
    ParamsFor<mat3x3<f32>, mat3x3<f32>, mat3x3<f32>>(Op::kSubtract),

    // Comparison expressions
    // https://gpuweb.github.io/gpuweb/wgsl.html#comparison-expr

    // Comparisons over scalars
    ParamsFor<bool, bool, bool>(Op::kEqual),
    ParamsFor<bool, bool, bool>(Op::kNotEqual),

    ParamsFor<i32, i32, bool>(Op::kEqual),
    ParamsFor<i32, i32, bool>(Op::kNotEqual),
    ParamsFor<i32, i32, bool>(Op::kLessThan),
    ParamsFor<i32, i32, bool>(Op::kLessThanEqual),
    ParamsFor<i32, i32, bool>(Op::kGreaterThan),
    ParamsFor<i32, i32, bool>(Op::kGreaterThanEqual),

    ParamsFor<u32, u32, bool>(Op::kEqual),
    ParamsFor<u32, u32, bool>(Op::kNotEqual),
    ParamsFor<u32, u32, bool>(Op::kLessThan),
    ParamsFor<u32, u32, bool>(Op::kLessThanEqual),
    ParamsFor<u32, u32, bool>(Op::kGreaterThan),
    ParamsFor<u32, u32, bool>(Op::kGreaterThanEqual),

    ParamsFor<f32, f32, bool>(Op::kEqual),
    ParamsFor<f32, f32, bool>(Op::kNotEqual),
    ParamsFor<f32, f32, bool>(Op::kLessThan),
    ParamsFor<f32, f32, bool>(Op::kLessThanEqual),
    ParamsFor<f32, f32, bool>(Op::kGreaterThan),
    ParamsFor<f32, f32, bool>(Op::kGreaterThanEqual),

    // Comparisons over vectors
    ParamsFor<vec3<bool>, vec3<bool>, vec3<bool>>(Op::kEqual),
    ParamsFor<vec3<bool>, vec3<bool>, vec3<bool>>(Op::kNotEqual),

    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kEqual),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kNotEqual),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kLessThan),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kLessThanEqual),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kGreaterThan),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<bool>>(Op::kGreaterThanEqual),

    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kEqual),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kNotEqual),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kLessThan),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kLessThanEqual),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kGreaterThan),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<bool>>(Op::kGreaterThanEqual),

    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kEqual),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kNotEqual),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kLessThan),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kLessThanEqual),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kGreaterThan),
    ParamsFor<vec3<f32>, vec3<f32>, vec3<bool>>(Op::kGreaterThanEqual),

    // Binary bitwise operations
    ParamsFor<i32, i32, i32>(Op::kOr),
    ParamsFor<i32, i32, i32>(Op::kAnd),
    ParamsFor<i32, i32, i32>(Op::kXor),

    ParamsFor<u32, u32, u32>(Op::kOr),
    ParamsFor<u32, u32, u32>(Op::kAnd),
    ParamsFor<u32, u32, u32>(Op::kXor),

    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kOr),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kAnd),
    ParamsFor<vec3<i32>, vec3<i32>, vec3<i32>>(Op::kXor),

    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kOr),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kAnd),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kXor),

    // Bit shift expressions
    ParamsFor<i32, u32, i32>(Op::kShiftLeft),
    ParamsFor<vec3<i32>, vec3<u32>, vec3<i32>>(Op::kShiftLeft),

    ParamsFor<u32, u32, u32>(Op::kShiftLeft),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kShiftLeft),

    ParamsFor<i32, u32, i32>(Op::kShiftRight),
    ParamsFor<vec3<i32>, vec3<u32>, vec3<i32>>(Op::kShiftRight),

    ParamsFor<u32, u32, u32>(Op::kShiftRight),
    ParamsFor<vec3<u32>, vec3<u32>, vec3<u32>>(Op::kShiftRight),
};

using Expr_Binary_Test_Valid = ResolverTestWithParam<Params>;
TEST_P(Expr_Binary_Test_Valid, All) {
    auto& params = GetParam();

    ast::Type lhs_type = params.create_lhs_type(*this);
    ast::Type rhs_type = params.create_rhs_type(*this);
    auto* result_type = params.create_result_type(*this);

    StringStream ss;
    ss << FriendlyName(lhs_type) << " " << params.op << " " << FriendlyName(rhs_type);
    SCOPED_TRACE(ss.str());

    GlobalVar("lhs", lhs_type, core::AddressSpace::kPrivate);
    GlobalVar("rhs", rhs_type, core::AddressSpace::kPrivate);

    auto* expr = create<ast::BinaryExpression>(params.op, Expr("lhs"), Expr("rhs"));
    WrapInFunction(expr);

    ASSERT_TRUE(r()->Resolve()) << r()->error();
    ASSERT_NE(TypeOf(expr), nullptr);
    ASSERT_TRUE(TypeOf(expr) == result_type);
}
INSTANTIATE_TEST_SUITE_P(ResolverTest, Expr_Binary_Test_Valid, testing::ValuesIn(all_valid_cases));

enum class BinaryExprSide { Left, Right, Both };
using Expr_Binary_Test_WithAlias_Valid = ResolverTestWithParam<std::tuple<Params, BinaryExprSide>>;
TEST_P(Expr_Binary_Test_WithAlias_Valid, All) {
    const Params& params = std::get<0>(GetParam());
    BinaryExprSide side = std::get<1>(GetParam());

    auto* create_lhs_type = (side == BinaryExprSide::Left || side == BinaryExprSide::Both)
                                ? params.create_lhs_alias_type
                                : params.create_lhs_type;
    auto* create_rhs_type = (side == BinaryExprSide::Right || side == BinaryExprSide::Both)
                                ? params.create_rhs_alias_type
                                : params.create_rhs_type;

    ast::Type lhs_type = create_lhs_type(*this);
    ast::Type rhs_type = create_rhs_type(*this);

    StringStream ss;
    ss << FriendlyName(lhs_type) << " " << params.op << " " << FriendlyName(rhs_type);

    ss << ", After aliasing: " << FriendlyName(lhs_type) << " " << params.op << " "
       << FriendlyName(rhs_type);
    SCOPED_TRACE(ss.str());

    GlobalVar("lhs", lhs_type, core::AddressSpace::kPrivate);
    GlobalVar("rhs", rhs_type, core::AddressSpace::kPrivate);

    auto* expr = create<ast::BinaryExpression>(params.op, Expr("lhs"), Expr("rhs"));
    WrapInFunction(expr);

    ASSERT_TRUE(r()->Resolve()) << r()->error();
    ASSERT_NE(TypeOf(expr), nullptr);
    // TODO(amaiorano): Bring this back once we have a way to get the canonical
    // type
    // auto* *result_type = params.create_result_type(*this);
    // ASSERT_TRUE(TypeOf(expr) == result_type);
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
                         Expr_Binary_Test_WithAlias_Valid,
                         testing::Combine(testing::ValuesIn(all_valid_cases),
                                          testing::Values(BinaryExprSide::Left,
                                                          BinaryExprSide::Right,
                                                          BinaryExprSide::Both)));

// This test works by taking the cartesian product of all possible
// (type * type * op), and processing only the triplets that are not found in
// the `all_valid_cases` table.
using Expr_Binary_Test_Invalid = ResolverTestWithParam<
    std::tuple<builder::ast_type_func_ptr, builder::ast_type_func_ptr, core::BinaryOp>>;
TEST_P(Expr_Binary_Test_Invalid, All) {
    const builder::ast_type_func_ptr& lhs_create_type_func = std::get<0>(GetParam());
    const builder::ast_type_func_ptr& rhs_create_type_func = std::get<1>(GetParam());
    const core::BinaryOp op = std::get<2>(GetParam());

    // Skip if valid case
    // TODO(amaiorano): replace linear lookup with O(1) if too slow
    for (auto& c : all_valid_cases) {
        if (c.create_lhs_type == lhs_create_type_func &&
            c.create_rhs_type == rhs_create_type_func && c.op == op) {
            return;
        }
    }

    ast::Type lhs_type = lhs_create_type_func(*this);
    ast::Type rhs_type = rhs_create_type_func(*this);

    StringStream ss;
    ss << FriendlyName(lhs_type) << " " << op << " " << FriendlyName(rhs_type);
    SCOPED_TRACE(ss.str());

    GlobalVar("lhs", lhs_type, core::AddressSpace::kPrivate);
    GlobalVar("rhs", rhs_type, core::AddressSpace::kPrivate);

    auto* expr = create<ast::BinaryExpression>(Source{{12, 34}}, op, Expr("lhs"), Expr("rhs"));
    WrapInFunction(expr);

    ASSERT_FALSE(r()->Resolve());
    EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching overload for 'operator "));
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
                         Expr_Binary_Test_Invalid,
                         testing::Combine(testing::ValuesIn(all_create_type_funcs),
                                          testing::ValuesIn(all_create_type_funcs),
                                          testing::ValuesIn(all_ops)));

using Expr_Binary_Test_Invalid_VectorMatrixMultiply =
    ResolverTestWithParam<std::tuple<bool, uint32_t, uint32_t, uint32_t>>;
TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) {
    bool vec_by_mat = std::get<0>(GetParam());
    uint32_t vec_size = std::get<1>(GetParam());
    uint32_t mat_rows = std::get<2>(GetParam());
    uint32_t mat_cols = std::get<3>(GetParam());

    ast::Type lhs_type;
    ast::Type rhs_type;
    const core::type::Type* result_type = nullptr;
    bool is_valid_expr;

    if (vec_by_mat) {
        lhs_type = ty.vec<f32>(vec_size);
        rhs_type = ty.mat<f32>(mat_cols, mat_rows);
        result_type = create<core::type::Vector>(create<core::type::F32>(), mat_cols);
        is_valid_expr = vec_size == mat_rows;
    } else {
        lhs_type = ty.mat<f32>(mat_cols, mat_rows);
        rhs_type = ty.vec<f32>(vec_size);
        result_type = create<core::type::Vector>(create<core::type::F32>(), mat_rows);
        is_valid_expr = vec_size == mat_cols;
    }

    GlobalVar("lhs", lhs_type, core::AddressSpace::kPrivate);
    GlobalVar("rhs", rhs_type, core::AddressSpace::kPrivate);

    auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs"));
    WrapInFunction(expr);

    if (is_valid_expr) {
        ASSERT_TRUE(r()->Resolve()) << r()->error();
        ASSERT_TRUE(TypeOf(expr) == result_type);
    } else {
        ASSERT_FALSE(r()->Resolve());
        EXPECT_THAT(r()->error(), HasSubstr("no matching overload for 'operator *"));
    }
}
auto all_dimension_values = testing::Values(2u, 3u, 4u);
INSTANTIATE_TEST_SUITE_P(ResolverTest,
                         Expr_Binary_Test_Invalid_VectorMatrixMultiply,
                         testing::Combine(testing::Values(true, false),
                                          all_dimension_values,
                                          all_dimension_values,
                                          all_dimension_values));

using Expr_Binary_Test_Invalid_MatrixMatrixMultiply =
    ResolverTestWithParam<std::tuple<uint32_t, uint32_t, uint32_t, uint32_t>>;
TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) {
    uint32_t lhs_mat_rows = std::get<0>(GetParam());
    uint32_t lhs_mat_cols = std::get<1>(GetParam());
    uint32_t rhs_mat_rows = std::get<2>(GetParam());
    uint32_t rhs_mat_cols = std::get<3>(GetParam());

    auto lhs_type = ty.mat<f32>(lhs_mat_cols, lhs_mat_rows);
    auto rhs_type = ty.mat<f32>(rhs_mat_cols, rhs_mat_rows);

    auto* f32 = create<core::type::F32>();
    auto* col = create<core::type::Vector>(f32, lhs_mat_rows);
    auto* result_type = create<core::type::Matrix>(col, rhs_mat_cols);

    GlobalVar("lhs", lhs_type, core::AddressSpace::kPrivate);
    GlobalVar("rhs", rhs_type, core::AddressSpace::kPrivate);

    auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs"));
    WrapInFunction(expr);

    bool is_valid_expr = lhs_mat_cols == rhs_mat_rows;
    if (is_valid_expr) {
        ASSERT_TRUE(r()->Resolve()) << r()->error();
        ASSERT_TRUE(TypeOf(expr) == result_type);
    } else {
        ASSERT_FALSE(r()->Resolve());
        EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching overload for 'operator * "));
    }
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
                         Expr_Binary_Test_Invalid_MatrixMatrixMultiply,
                         testing::Combine(all_dimension_values,
                                          all_dimension_values,
                                          all_dimension_values,
                                          all_dimension_values));

}  // namespace ExprBinaryTest

using UnaryOpExpressionTest = ResolverTestWithParam<core::UnaryOp>;
TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
    auto op = GetParam();

    if (op == core::UnaryOp::kNot) {
        GlobalVar("ident", ty.vec4<bool>(), core::AddressSpace::kPrivate);
    } else if (op == core::UnaryOp::kNegation || op == core::UnaryOp::kComplement) {
        GlobalVar("ident", ty.vec4<i32>(), core::AddressSpace::kPrivate);
    } else {
        GlobalVar("ident", ty.vec4<f32>(), core::AddressSpace::kPrivate);
    }
    auto* der = create<ast::UnaryOpExpression>(op, Expr("ident"));
    WrapInFunction(der);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(TypeOf(der), nullptr);
    ASSERT_TRUE(TypeOf(der)->Is<core::type::Vector>());
    if (op == core::UnaryOp::kNot) {
        EXPECT_TRUE(TypeOf(der)->As<core::type::Vector>()->Type()->Is<core::type::Bool>());
    } else if (op == core::UnaryOp::kNegation || op == core::UnaryOp::kComplement) {
        EXPECT_TRUE(TypeOf(der)->As<core::type::Vector>()->Type()->Is<core::type::I32>());
    } else {
        EXPECT_TRUE(TypeOf(der)->As<core::type::Vector>()->Type()->Is<core::type::F32>());
    }
    EXPECT_EQ(TypeOf(der)->As<core::type::Vector>()->Width(), 4u);
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
                         UnaryOpExpressionTest,
                         testing::Values(core::UnaryOp::kComplement,
                                         core::UnaryOp::kNegation,
                                         core::UnaryOp::kNot));

TEST_F(ResolverTest, AddressSpace_SetsIfMissing) {
    auto* var = Var("var", ty.i32());

    auto* stmt = Decl(var);
    Func("func", tint::Empty, ty.void_(), Vector{stmt});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get(var)->AddressSpace(), core::AddressSpace::kFunction);
}

TEST_F(ResolverTest, AddressSpace_SetForSampler) {
    auto t = ty.sampler(core::type::SamplerKind::kSampler);
    auto* var = GlobalVar("var", t, Binding(0_a), Group(0_a));

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get(var)->AddressSpace(), core::AddressSpace::kHandle);
}

TEST_F(ResolverTest, AddressSpace_SetForTexture) {
    auto t = ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32());
    auto* var = GlobalVar("var", t, Binding(0_a), Group(0_a));

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get(var)->AddressSpace(), core::AddressSpace::kHandle);
}

TEST_F(ResolverTest, AddressSpace_DoesNotSetOnConst) {
    auto* var = Let("var", ty.i32(), Call<i32>());
    auto* stmt = Decl(var);
    Func("func", tint::Empty, ty.void_(), Vector{stmt});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get(var)->AddressSpace(), core::AddressSpace::kUndefined);
}

TEST_F(ResolverTest, Access_SetForStorageBuffer) {
    // struct S { x : i32 };
    // var<storage> g : S;
    auto* s = Structure("S", Vector{Member(Source{{12, 34}}, "x", ty.i32())});
    auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), core::AddressSpace::kStorage,
                          Binding(0_a), Group(0_a));

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get(var)->Access(), core::Access::kRead);
}

TEST_F(ResolverTest, BindingPoint_SetForResources) {
    // @group(1) @binding(2) var s1 : sampler;
    // @group(3) @binding(4) var s2 : sampler;
    auto* s1 =
        GlobalVar(Sym(), ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));
    auto* s2 =
        GlobalVar(Sym(), ty.sampler(core::type::SamplerKind::kSampler), Group(3_a), Binding(4_a));

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    EXPECT_EQ(Sem().Get<sem::GlobalVariable>(s1)->Attributes().binding_point,
              (BindingPoint{1u, 2u}));
    EXPECT_EQ(Sem().Get<sem::GlobalVariable>(s2)->Attributes().binding_point,
              (BindingPoint{3u, 4u}));
}

TEST_F(ResolverTest, Function_EntryPoints_StageAttribute) {
    // fn b() {}
    // fn c() { b(); }
    // fn a() { c(); }
    // fn ep_1() { a(); b(); }
    // fn ep_2() { c();}
    //
    // c -> {ep_1, ep_2}
    // a -> {ep_1}
    // b -> {ep_1, ep_2}
    // ep_1 -> {}
    // ep_2 -> {}

    GlobalVar("first", ty.f32(), core::AddressSpace::kPrivate);
    GlobalVar("second", ty.f32(), core::AddressSpace::kPrivate);
    GlobalVar("call_a", ty.f32(), core::AddressSpace::kPrivate);
    GlobalVar("call_b", ty.f32(), core::AddressSpace::kPrivate);
    GlobalVar("call_c", ty.f32(), core::AddressSpace::kPrivate);

    auto* func_b = Func("b", tint::Empty, ty.f32(),
                        Vector{
                            Return(0_f),
                        });
    auto* func_c = Func("c", tint::Empty, ty.f32(),
                        Vector{
                            Assign("second", Call("b")),
                            Return(0_f),
                        });

    auto* func_a = Func("a", tint::Empty, ty.f32(),
                        Vector{
                            Assign("first", Call("c")),
                            Return(0_f),
                        });

    auto* ep_1 = Func("ep_1", tint::Empty, ty.void_(),
                      Vector{
                          Assign("call_a", Call("a")),
                          Assign("call_b", Call("b")),
                      },
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize(1_i),
                      });

    auto* ep_2 = Func("ep_2", tint::Empty, ty.void_(),
                      Vector{
                          Assign("call_c", Call("c")),
                      },
                      Vector{
                          Stage(ast::PipelineStage::kCompute),
                          WorkgroupSize(1_i),
                      });

    ASSERT_TRUE(r()->Resolve()) << r()->error();

    auto* func_b_sem = Sem().Get(func_b);
    auto* func_a_sem = Sem().Get(func_a);
    auto* func_c_sem = Sem().Get(func_c);
    auto* ep_1_sem = Sem().Get(ep_1);
    auto* ep_2_sem = Sem().Get(ep_2);
    ASSERT_NE(func_b_sem, nullptr);
    ASSERT_NE(func_a_sem, nullptr);
    ASSERT_NE(func_c_sem, nullptr);
    ASSERT_NE(ep_1_sem, nullptr);
    ASSERT_NE(ep_2_sem, nullptr);

    EXPECT_EQ(func_b_sem->Parameters().Length(), 0u);
    EXPECT_EQ(func_a_sem->Parameters().Length(), 0u);
    EXPECT_EQ(func_c_sem->Parameters().Length(), 0u);

    const auto& b_eps = func_b_sem->AncestorEntryPoints();
    ASSERT_EQ(2u, b_eps.Length());
    EXPECT_EQ(Symbols().Register("ep_1"), b_eps[0]->Declaration()->name->symbol);
    EXPECT_EQ(Symbols().Register("ep_2"), b_eps[1]->Declaration()->name->symbol);

    const auto& a_eps = func_a_sem->AncestorEntryPoints();
    ASSERT_EQ(1u, a_eps.Length());
    EXPECT_EQ(Symbols().Register("ep_1"), a_eps[0]->Declaration()->name->symbol);

    const auto& c_eps = func_c_sem->AncestorEntryPoints();
    ASSERT_EQ(2u, c_eps.Length());
    EXPECT_EQ(Symbols().Register("ep_1"), c_eps[0]->Declaration()->name->symbol);
    EXPECT_EQ(Symbols().Register("ep_2"), c_eps[1]->Declaration()->name->symbol);

    EXPECT_TRUE(ep_1_sem->AncestorEntryPoints().IsEmpty());
    EXPECT_TRUE(ep_2_sem->AncestorEntryPoints().IsEmpty());
}

// Check for linear-time traversal of functions reachable from entry points.
// See: crbug.com/tint/245
TEST_F(ResolverTest, Function_EntryPoints_LinearTime) {
    // fn lNa() { }
    // fn lNb() { }
    // ...
    // fn l2a() { l3a(); l3b(); }
    // fn l2b() { l3a(); l3b(); }
    // fn l1a() { l2a(); l2b(); }
    // fn l1b() { l2a(); l2b(); }
    // fn main() { l1a(); l1b(); }

    static constexpr int levels = 64;

    auto fn_a = [](int level) { return "l" + std::to_string(level + 1) + "a"; };
    auto fn_b = [](int level) { return "l" + std::to_string(level + 1) + "b"; };

    Func(fn_a(levels), tint::Empty, ty.void_(), tint::Empty);
    Func(fn_b(levels), tint::Empty, ty.void_(), tint::Empty);

    for (int i = levels - 1; i >= 0; i--) {
        Func(fn_a(i), tint::Empty, ty.void_(),
             Vector{
                 CallStmt(Call(fn_a(i + 1))),
                 CallStmt(Call(fn_b(i + 1))),
             },
             tint::Empty);
        Func(fn_b(i), tint::Empty, ty.void_(),
             Vector{
                 CallStmt(Call(fn_a(i + 1))),
                 CallStmt(Call(fn_b(i + 1))),
             },
             tint::Empty);
    }

    Func("main", tint::Empty, ty.void_(),
         Vector{
             CallStmt(Call(fn_a(0))),
             CallStmt(Call(fn_b(0))),
         },
         Vector{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});

    ASSERT_TRUE(r()->Resolve()) << r()->error();
}

// Test for crbug.com/tint/728
TEST_F(ResolverTest, ASTNodesAreReached) {
    Structure("A", Vector{Member("x", ty.array<f32, 4>(Vector{Stride(4)}))});
    Structure("B", Vector{Member("x", ty.array<f32, 4>(Vector{Stride(4)}))});
    ASSERT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverDeathTest, ASTNodeNotReached) {
    EXPECT_DEATH_IF_SUPPORTED(
        {
            ProgramBuilder b;
            b.Ident("ident");
            Resolver(&b, {}).Resolve();
        },
        "internal compiler error: AST node 'tint::ast::Identifier' was not reached by the "
        "resolver");
}

TEST_F(ResolverDeathTest, ASTNodeReachedTwice) {
    EXPECT_DEATH_IF_SUPPORTED(
        {
            ProgramBuilder b;
            auto* expr = b.Expr(1_i);
            b.GlobalVar("a", b.ty.i32(), core::AddressSpace::kPrivate, expr);
            b.GlobalVar("b", b.ty.i32(), core::AddressSpace::kPrivate, expr);
            Resolver(&b, {}).Resolve();
        },
        "internal compiler error: AST node 'tint::ast::IntLiteralExpression' was encountered twice "
        "in the same AST of a Program");
}

TEST_F(ResolverTest, UnaryOp_Not) {
    GlobalVar("ident", ty.vec4<f32>(), core::AddressSpace::kPrivate);
    auto* der =
        create<ast::UnaryOpExpression>(core::UnaryOp::kNot, Expr(Source{{12, 34}}, "ident"));
    WrapInFunction(der);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_THAT(r()->error(), HasSubstr("error: no matching overload for 'operator ! (vec4<f32>)"));
}

TEST_F(ResolverTest, UnaryOp_Complement) {
    GlobalVar("ident", ty.vec4<f32>(), core::AddressSpace::kPrivate);
    auto* der =
        create<ast::UnaryOpExpression>(core::UnaryOp::kComplement, Expr(Source{{12, 34}}, "ident"));
    WrapInFunction(der);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_THAT(r()->error(), HasSubstr("error: no matching overload for 'operator ~ (vec4<f32>)"));
}

TEST_F(ResolverTest, UnaryOp_Negation) {
    GlobalVar("ident", ty.u32(), core::AddressSpace::kPrivate);
    auto* der =
        create<ast::UnaryOpExpression>(core::UnaryOp::kNegation, Expr(Source{{12, 34}}, "ident"));
    WrapInFunction(der);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_THAT(r()->error(), HasSubstr("error: no matching overload for 'operator - (u32)"));
}

TEST_F(ResolverTest, TextureSampler_TextureSample) {
    GlobalVar("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("s", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));

    auto* call = Call("textureSample", "t", "s", Call<vec2<f32>>(1_f, 2_f));
    const ast::Function* f =
        Func("test_function", tint::Empty, ty.void_(), Vector{Assign(Phony(), call)},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    const sem::Function* sf = Sem().Get(f);
    auto pairs = sf->TextureSamplerPairs();
    ASSERT_EQ(pairs.Length(), 1u);
    EXPECT_TRUE(pairs[0].first != nullptr);
    EXPECT_TRUE(pairs[0].second != nullptr);
}

TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
    GlobalVar("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("s", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));

    auto* inner_call = Assign(Phony(), Call("textureSample", "t", "s", Call<vec2<f32>>(1_f, 2_f)));
    const ast::Function* inner_func =
        Func("inner_func", tint::Empty, ty.void_(), Vector{inner_call});
    auto* outer_call = CallStmt(Call("inner_func"));
    const ast::Function* outer_func =
        Func("outer_func", tint::Empty, ty.void_(), Vector{outer_call},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto inner_pairs = Sem().Get(inner_func)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs.Length(), 1u);
    EXPECT_TRUE(inner_pairs[0].first != nullptr);
    EXPECT_TRUE(inner_pairs[0].second != nullptr);

    auto outer_pairs = Sem().Get(outer_func)->TextureSamplerPairs();
    ASSERT_EQ(outer_pairs.Length(), 1u);
    EXPECT_TRUE(outer_pairs[0].first != nullptr);
    EXPECT_TRUE(outer_pairs[0].second != nullptr);
}

TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
    GlobalVar("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("s", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));

    auto* inner_call_1 =
        Assign(Phony(), Call("textureSample", "t", "s", Call<vec2<f32>>(1_f, 2_f)));
    const ast::Function* inner_func_1 =
        Func("inner_func_1", tint::Empty, ty.void_(), Vector{inner_call_1});
    auto* inner_call_2 =
        Assign(Phony(), Call("textureSample", "t", "s", Call<vec2<f32>>(3_f, 4_f)));
    const ast::Function* inner_func_2 =
        Func("inner_func_2", tint::Empty, ty.void_(), Vector{inner_call_2});
    auto* outer_call_1 = CallStmt(Call("inner_func_1"));
    auto* outer_call_2 = CallStmt(Call("inner_func_2"));
    const ast::Function* outer_func =
        Func("outer_func", tint::Empty, ty.void_(), Vector{outer_call_1, outer_call_2},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto inner_pairs_1 = Sem().Get(inner_func_1)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs_1.Length(), 1u);
    EXPECT_TRUE(inner_pairs_1[0].first != nullptr);
    EXPECT_TRUE(inner_pairs_1[0].second != nullptr);

    auto inner_pairs_2 = Sem().Get(inner_func_2)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs_1.Length(), 1u);
    EXPECT_TRUE(inner_pairs_2[0].first != nullptr);
    EXPECT_TRUE(inner_pairs_2[0].second != nullptr);

    auto outer_pairs = Sem().Get(outer_func)->TextureSamplerPairs();
    ASSERT_EQ(outer_pairs.Length(), 1u);
    EXPECT_TRUE(outer_pairs[0].first != nullptr);
    EXPECT_TRUE(outer_pairs[0].second != nullptr);
}

TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariables) {
    GlobalVar("t1", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("t2", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(2_a));
    GlobalVar("s", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(3_a));

    auto* inner_call_1 =
        Assign(Phony(), Call("textureSample", "t1", "s", Call<vec2<f32>>(1_f, 2_f)));
    const ast::Function* inner_func_1 =
        Func("inner_func_1", tint::Empty, ty.void_(), Vector{inner_call_1});
    auto* inner_call_2 =
        Assign(Phony(), Call("textureSample", "t2", "s", Call<vec2<f32>>(3_f, 4_f)));
    const ast::Function* inner_func_2 =
        Func("inner_func_2", tint::Empty, ty.void_(), Vector{inner_call_2});
    auto* outer_call_1 = CallStmt(Call("inner_func_1"));
    auto* outer_call_2 = CallStmt(Call("inner_func_2"));
    const ast::Function* outer_func =
        Func("outer_func", tint::Empty, ty.void_(), Vector{outer_call_1, outer_call_2},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto inner_pairs_1 = Sem().Get(inner_func_1)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs_1.Length(), 1u);
    EXPECT_TRUE(inner_pairs_1[0].first != nullptr);
    EXPECT_TRUE(inner_pairs_1[0].second != nullptr);

    auto inner_pairs_2 = Sem().Get(inner_func_2)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs_2.Length(), 1u);
    EXPECT_TRUE(inner_pairs_2[0].first != nullptr);
    EXPECT_TRUE(inner_pairs_2[0].second != nullptr);

    auto outer_pairs = Sem().Get(outer_func)->TextureSamplerPairs();
    ASSERT_EQ(outer_pairs.Length(), 2u);
    EXPECT_TRUE(outer_pairs[0].first == inner_pairs_1[0].first);
    EXPECT_TRUE(outer_pairs[0].second == inner_pairs_1[0].second);
    EXPECT_TRUE(outer_pairs[1].first == inner_pairs_2[0].first);
    EXPECT_TRUE(outer_pairs[1].second == inner_pairs_2[0].second);
}

TEST_F(ResolverTest, TextureSampler_TextureSampleInFunctionPassedAsArguments) {
    GlobalVar("gt", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("gs", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));

    auto* inner_coords = Param("coords", ty.vec2<f32>());
    auto* inner_t = Param("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()));
    auto* inner_s = Param("s", ty.sampler(core::type::SamplerKind::kSampler));
    auto* inner_call = Assign(Phony(), Call("textureSample", inner_t, inner_s, inner_coords));
    const ast::Function* inner_func =
        Func("inner_func", Vector{inner_coords, inner_t, inner_s}, ty.void_(), Vector{inner_call});

    auto* middle_coords = Param("coords", ty.vec2<f32>());
    auto* middle_s = Param("s", ty.sampler(core::type::SamplerKind::kSampler));
    auto* middle_t = Param("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()));
    auto* middle_call = CallStmt(Call("inner_func", middle_coords, "t", "s"));
    const ast::Function* middle_func = Func(
        "middle_func", Vector{middle_coords, middle_s, middle_t}, ty.void_(), Vector{middle_call});

    auto* outer_call = CallStmt(Call("middle_func", Call<vec2<f32>>(1_f, 2_f), "gs", "gt"));
    const ast::Function* outer_func =
        Func("outer_func", tint::Empty, ty.void_(), Vector{outer_call},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto inner_pairs = Sem().Get(inner_func)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs.Length(), 1u);
    auto* inner_pair_texture = As<sem::Parameter>(inner_pairs[0].first);
    ASSERT_NE(inner_pair_texture, nullptr);
    EXPECT_EQ(inner_pair_texture->Index(), 1u);
    auto* inner_pair_sampler = As<sem::Parameter>(inner_pairs[0].second);
    ASSERT_NE(inner_pair_sampler, nullptr);
    EXPECT_EQ(inner_pair_sampler->Index(), 2u);

    auto middle_pairs = Sem().Get(middle_func)->TextureSamplerPairs();
    ASSERT_EQ(middle_pairs.Length(), 1u);
    auto* middle_pair_texture = As<sem::Parameter>(middle_pairs[0].first);
    ASSERT_NE(middle_pair_texture, nullptr);
    EXPECT_EQ(middle_pair_texture->Index(), 2u);
    auto* middle_pair_sampler = As<sem::Parameter>(middle_pairs[0].second);
    ASSERT_NE(middle_pair_sampler, nullptr);
    EXPECT_EQ(middle_pair_sampler->Index(), 1u);

    auto outer_pairs = Sem().Get(outer_func)->TextureSamplerPairs();
    ASSERT_EQ(outer_pairs.Length(), 1u);
    EXPECT_TRUE(outer_pairs[0].first != nullptr);
    EXPECT_TRUE(outer_pairs[0].second != nullptr);
}

TEST_F(ResolverTest, TextureSampler_UnusedTextureSampleInFunctionPassedAsArguments) {
    GlobalVar("gt", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(1_a));
    GlobalVar("gs", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a), Binding(2_a));

    auto* inner_coords = Param("coords", ty.vec2<f32>());
    auto* inner_t = Param("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()));
    auto* inner_s = Param("s", ty.sampler(core::type::SamplerKind::kSampler));
    const ast::Function* inner_func =
        Func("inner_func", Vector{inner_coords, inner_t, inner_s}, ty.void_(), Empty);

    auto* middle_coords = Param("coords", ty.vec2<f32>());
    auto* middle_s = Param("s", ty.sampler(core::type::SamplerKind::kSampler));
    auto* middle_t = Param("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()));
    auto* middle_call = CallStmt(Call("inner_func", middle_coords, "t", "s"));
    const ast::Function* middle_func = Func(
        "middle_func", Vector{middle_coords, middle_s, middle_t}, ty.void_(), Vector{middle_call});

    auto* outer_call = CallStmt(Call("middle_func", Call<vec2<f32>>(1_f, 2_f), "gs", "gt"));
    const ast::Function* outer_func =
        Func("outer_func", tint::Empty, ty.void_(), Vector{outer_call},
             Vector{Stage(ast::PipelineStage::kFragment)});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto inner_pairs = Sem().Get(inner_func)->TextureSamplerPairs();
    ASSERT_EQ(inner_pairs.Length(), 0u);

    auto middle_pairs = Sem().Get(middle_func)->TextureSamplerPairs();
    ASSERT_EQ(middle_pairs.Length(), 0u);

    auto outer_pairs = Sem().Get(outer_func)->TextureSamplerPairs();
    ASSERT_EQ(outer_pairs.Length(), 0u);
}

TEST_F(ResolverTest, TextureSampler_TextureDimensions) {
    GlobalVar("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(1_a),
              Binding(2_a));

    auto* call = Call("textureDimensions", "t");
    const ast::Function* f = WrapInFunction(call);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    const sem::Function* sf = Sem().Get(f);
    auto pairs = sf->TextureSamplerPairs();
    ASSERT_EQ(pairs.Length(), 1u);
    EXPECT_TRUE(pairs[0].first != nullptr);
    EXPECT_TRUE(pairs[0].second == nullptr);
}

TEST_F(ResolverTest, TextureSampler_Bug1715) {  // crbug.com/tint/1715
    // @binding(0) @group(0) var s: sampler;
    // @binding(1) @group(0) var t: texture_2d<f32>;
    // @binding(2) @group(0) var<uniform> c: vec2<f32>;
    //
    // @fragment
    // fn main() -> @location(0) vec4<f32> {
    //     return helper(&s, &t);
    // }
    //
    // fn helper(sl: ptr<function, sampler>, tl: ptr<function, texture_2d<f32>>) -> vec4<f32> {
    //     return textureSampleLevel(*tl, *sl, c, 0.0);
    // }
    GlobalVar("s", ty.sampler(core::type::SamplerKind::kSampler), Group(0_a), Binding(0_a));
    GlobalVar("t", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Group(0_a),
              Binding(1_a));
    GlobalVar("c", ty.vec2<f32>(), core::AddressSpace::kUniform, Group(0_a), Binding(2_a));

    Func("main", tint::Empty, ty.vec4<f32>(),
         Vector{
             Return(Call("helper", AddressOf("s"), AddressOf("t"))),
         },
         Vector{
             Stage(ast::PipelineStage::kFragment),
         },
         Vector{
             Location(0_u),
         });

    Func("helper",
         Vector{
             Param("sl", ty.ptr<function>(ty.sampler(core::type::SamplerKind::kSampler))),
             Param("tl", ty.ptr<function>(
                             ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()))),
         },
         ty.vec4<f32>(),
         Vector{
             Return(Call("textureSampleLevel", Deref("tl"), Deref("sl"), "c", 0.0_a)),
         });

    ASSERT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "error: pointer can not be formed to a sampler");
}

TEST_F(ResolverTest, ModuleDependencyOrderedDeclarations) {
    auto* f0 = Func("f0", tint::Empty, ty.void_(), tint::Empty);
    auto* v0 = GlobalVar("v0", ty.i32(), core::AddressSpace::kPrivate);
    auto* a0 = Alias("a0", ty.i32());
    auto* s0 = Structure("s0", Vector{Member("m", ty.i32())});
    auto* f1 = Func("f1", tint::Empty, ty.void_(), tint::Empty);
    auto* v1 = GlobalVar("v1", ty.i32(), core::AddressSpace::kPrivate);
    auto* a1 = Alias("a1", ty.i32());
    auto* s1 = Structure("s1", Vector{Member("m", ty.i32())});
    auto* f2 = Func("f2", tint::Empty, ty.void_(), tint::Empty);
    auto* v2 = GlobalVar("v2", ty.i32(), core::AddressSpace::kPrivate);
    auto* a2 = Alias("a2", ty.i32());
    auto* s2 = Structure("s2", Vector{Member("m", ty.i32())});

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    ASSERT_NE(Sem().Module(), nullptr);
    EXPECT_THAT(Sem().Module()->DependencyOrderedDeclarations(),
                ElementsAre(f0, v0, a0, s0, f1, v1, a1, s1, f2, v2, a2, s2));
}

constexpr size_t kMaxExpressionDepth = 512U;

TEST_F(ResolverTest, MaxExpressionDepth_Pass) {
    auto* b = Var("b", ty.i32());
    const ast::Expression* chain = nullptr;
    for (size_t i = 0; i < kMaxExpressionDepth; ++i) {
        chain = Add(chain ? chain : Expr("b"), Expr("b"));
    }
    auto* a = Let("a", chain);
    WrapInFunction(b, a);

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxExpressionDepth_Fail) {
    auto* b = Var("b", ty.i32());
    const ast::Expression* chain = nullptr;
    for (size_t i = 0; i < kMaxExpressionDepth + 1; ++i) {
        chain = Add(chain ? chain : Expr("b"), Expr("b"));
    }
    auto* a = Let("a", chain);
    WrapInFunction(b, a);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_THAT(r()->error(), HasSubstr("error: reached max expression depth of " +
                                        std::to_string(kMaxExpressionDepth)));
}

// Windows debug builds have significantly smaller stack than other builds, and these tests will
// stack overflow.
#if !defined(NDEBUG)

TEST_F(ResolverTest, ScopeDepth_NestedBlocks) {
    const ast::Statement* stmt = Return();
    for (uint32_t i = 0; i < 150; i++) {
        stmt = Block(Source{{i, 1}}, stmt);
    }
    WrapInFunction(stmt);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              "23:1 error: statement nesting depth / chaining length exceeds limit of 127");
}

TEST_F(ResolverTest, ScopeDepth_NestedIf) {
    const ast::Statement* stmt = Return();
    for (uint32_t i = 0; i < 150; i++) {
        stmt = If(Source{{i, 1}}, false, Block(Source{{i, 2}}, stmt));
    }
    WrapInFunction(stmt);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              "86:1 error: statement nesting depth / chaining length exceeds limit of 127");
}

TEST_F(ResolverTest, ScopeDepth_IfElseChain) {
    const ast::Statement* stmt = nullptr;
    for (uint32_t i = 0; i < 150; i++) {
        stmt = If(Source{{i, 1}}, false, Block(Source{{i, 2}}), Else(stmt));
    }
    WrapInFunction(stmt);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              "24:2 error: statement nesting depth / chaining length exceeds limit of 127");
}

#endif  // !defined(NDEBUG)

const size_t kMaxNumStructMembers = 16383;

TEST_F(ResolverTest, MaxNumStructMembers_Valid) {
    Vector<const ast::StructMember*, 0> members;
    members.Reserve(kMaxNumStructMembers);
    for (size_t i = 0; i < kMaxNumStructMembers; ++i) {
        members.Push(Member("m" + std::to_string(i), ty.i32()));
    }
    Structure("S", std::move(members));
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNumStructMembers_Invalid) {
    Vector<const ast::StructMember*, 0> members;
    members.Reserve(kMaxNumStructMembers + 1);
    for (size_t i = 0; i < kMaxNumStructMembers + 1; ++i) {
        members.Push(Member("m" + std::to_string(i), ty.i32()));
    }
    Structure(Source{{12, 34}}, "S", std::move(members));
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: 'struct S' has 16384 members, maximum is 16383");
}

TEST_F(ResolverTest, MaxNumStructMembers_WithIgnoreStructMemberLimit_Valid) {
    Vector<const ast::StructMember*, 0> members;
    members.Reserve(kMaxNumStructMembers);
    for (size_t i = 0; i < kMaxNumStructMembers; ++i) {
        members.Push(Member("m" + std::to_string(i), ty.i32()));
    }

    // Add 10 more members, but we set the limit to be ignored on the struct
    for (size_t i = 0; i < 10; ++i) {
        members.Push(Member("ignored" + std::to_string(i), ty.i32()));
    }

    Structure("S", std::move(members),
              Vector{Disable(ast::DisabledValidation::kIgnoreStructMemberLimit)});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

uint32_t kMaxNestDepthOfCompositeType = 255;

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_Structs_Valid) {
    auto* s = Structure("S", Vector{Member("m", ty.i32())});
    uint32_t depth = 1;  // Depth of struct
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        s = Structure("S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_Structs_Invalid) {
    auto* s = Structure("S", Vector{Member("m", ty.i32())});
    uint32_t depth = 1;  // Depth of struct
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = i == iterations - 1 ? Source{{12, 34}} : Source{{0, i}};
        s = Structure(source, "S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: 'struct S254' has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsWithVector_Valid) {
    auto* s = Structure("S", Vector{Member("m", ty.vec3<i32>())});
    uint32_t depth = 2;  // Despth of struct + vector
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        s = Structure("S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsWithVector_Invalid) {
    auto* s = Structure("S", Vector{Member("m", ty.vec3<i32>())});
    uint32_t depth = 2;  // Despth of struct + vector
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = i == iterations - 1 ? Source{{12, 34}} : Source{{0, i}};
        s = Structure(source, "S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: 'struct S253' has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsWithMatrix_Valid) {
    auto* s = Structure("S", Vector{Member("m", ty.mat3x3<f32>())});
    uint32_t depth = 3;  // Depth of struct + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        s = Structure("S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsWithMatrix_Invalid) {
    auto* s = Structure("S", Vector{Member("m", ty.mat3x3<f32>())});
    uint32_t depth = 3;  // Depth of struct + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = i == iterations - 1 ? Source{{12, 34}} : Source{{0, i}};
        s = Structure(source, "S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: 'struct S252' has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_Arrays_Valid) {
    auto a = ty.array(ty.i32(), 10_u);
    uint32_t depth = 1;  // Depth of array
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        a = ty.array(a, 1_u);
    }
    Alias("a", a);
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_Arrays_Invalid) {
    auto a = ty.array(Source{{99, 88}}, ty.i32(), 10_u);
    uint32_t depth = 1;  // Depth of array
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = (i == iterations - 1) ? Source{{12, 34}} : Source{{0, i}};
        a = ty.array(source, a, 1_u);
    }
    Alias("a", a);
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: array has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfVector_Valid) {
    auto a = ty.array<vec3<i32>, 10>();
    uint32_t depth = 2;  // Depth of array + vector
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        a = ty.array(a, 1_u);
    }
    Alias("a", a);
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfVector_Invalid) {
    auto a = ty.array(Source{{99, 88}}, ty.vec3<i32>(), 10_u);
    uint32_t depth = 2;  // Depth of array + vector
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = (i == iterations - 1) ? Source{{12, 34}} : Source{{0, i}};
        a = ty.array(source, a, 1_u);
    }
    Alias("a", a);
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: array has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfMatrix_Valid) {
    auto a = ty.array(ty.mat3x3<f32>(), 10_u);
    uint32_t depth = 3;  // Depth of array + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        a = ty.array(a, 1_u);
    }
    Alias("a", a);
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfMatrix_Invalid) {
    auto a = ty.array(ty.mat3x3<f32>(), 10_u);
    uint32_t depth = 3;  // Depth of array + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = (i == iterations - 1) ? Source{{12, 34}} : Source{{0, i}};
        a = ty.array(source, a, 1_u);
    }
    Alias("a", a);
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: array has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsOfArray_Valid) {
    auto a = ty.array(ty.mat3x3<f32>(), 10_u);
    auto* s = Structure("S", Vector{Member("m", a)});
    uint32_t depth = 4;  // Depth of struct + array + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        s = Structure("S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_StructsOfArray_Invalid) {
    auto a = ty.array(ty.mat3x3<f32>(), 10_u);
    auto* s = Structure("S", Vector{Member("m", a)});
    uint32_t depth = 4;  // Depth of struct + array + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = i == iterations - 1 ? Source{{12, 34}} : Source{{0, i}};
        s = Structure(source, "S" + std::to_string(i), Vector{Member("m", ty.Of(s))});
    }
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: 'struct S251' has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfStruct_Valid) {
    auto* s = Structure("S", Vector{Member("m", ty.mat3x3<f32>())});
    auto a = ty.array(ty.Of(s), 10_u);
    uint32_t depth = 4;  // Depth of array + struct + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth;
    for (uint32_t i = 0; i < iterations; ++i) {
        a = ty.array(a, 1_u);
    }
    Alias("a", a);
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResolverTest, MaxNestDepthOfCompositeType_ArraysOfStruct_Invalid) {
    auto* s = Structure("S", Vector{Member("m", ty.mat3x3<f32>())});
    auto a = ty.array(ty.Of(s), 10_u);
    uint32_t depth = 4;  // Depth of array + struct + matrix
    uint32_t iterations = kMaxNestDepthOfCompositeType - depth + 1;
    for (uint32_t i = 0; i < iterations; ++i) {
        auto source = (i == iterations - 1) ? Source{{12, 34}} : Source{{0, i}};
        a = ty.array(source, a, 1_u);
    }
    Alias("a", a);
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: array has nesting depth of 256, maximum is 255");
}

TEST_F(ResolverTest, PointerToHandleTextureParameter) {
    Func("helper",
         Vector{
             Param("sl", ty.ptr<function>(
                             Source{{12, 34}},
                             ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32()))),
         },
         ty.void_(), {});

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleTextureReturn) {
    Func("helper", {},
         ty.ptr<function>(Source{{12, 34}},
                          ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32())),
         {});

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleSamplerParameter) {
    Func("helper",
         Vector{
             Param("sl", ty.ptr<function>(Source{{12, 34}},
                                          ty.sampler(core::type::SamplerKind::kSampler))),
         },
         ty.void_(), {});

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a sampler");
}

TEST_F(ResolverTest, PointerToHandleTextureParameterAlias) {
    auto* my_ty = Alias(
        "MyTy", ty.ptr<private_>(Source{{12, 34}},
                                 ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32())));
    Func("helper",
         Vector{
             Param("sl", ty.Of(my_ty)),
         },
         ty.void_(), {});

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleSamplerParameterAlias) {
    auto* my_ty = Alias(
        "MyTy", ty.ptr<private_>(Source{{12, 34}}, ty.sampler(core::type::SamplerKind::kSampler)));
    Func("helper",
         Vector{
             Param("sl", ty.Of(my_ty)),
         },
         ty.void_(), {});

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a sampler");
}

TEST_F(ResolverTest, PointerToHandleTextureVar) {
    GlobalVar("s",
              ty.ptr<private_>(Source{{12, 34}},
                               ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32())),
              core::AddressSpace::kPrivate, Group(0_a), Binding(0_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleSamplerVar) {
    GlobalVar("s",
              ty.ptr<private_>(Source{{12, 34}}, ty.sampler(core::type::SamplerKind::kSampler)),
              Group(0_a), core::AddressSpace::kPrivate, Binding(0_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a sampler");
}

TEST_F(ResolverTest, PointerToHandleTextureVarAlias) {
    auto* my_ty = Alias(
        "MyTy", ty.ptr<private_>(Source{{12, 34}},
                                 ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32())));
    GlobalVar("s", ty.Of(my_ty), core::AddressSpace::kPrivate, Group(0_a), Binding(0_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleSamplerVarAlias) {
    auto* my_ty = Alias(
        "MyTy", ty.ptr<private_>(Source{{12, 34}}, ty.sampler(core::type::SamplerKind::kSampler)));

    GlobalVar("s", ty.Of(my_ty), Group(0_a), core::AddressSpace::kPrivate, Binding(0_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a sampler");
}

TEST_F(ResolverTest, PointerToHandleTextureAlias) {
    Alias("MyTy",
          ty.ptr<private_>(Source{{12, 34}},
                           ty.sampled_texture(core::type::TextureDimension::k1d, ty.f32())));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a texture");
}

TEST_F(ResolverTest, PointerToHandleSamplerAlias) {
    Alias("MyTy",
          ty.ptr<private_>(Source{{12, 34}}, ty.sampler(core::type::SamplerKind::kSampler)));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: pointer can not be formed to a sampler");
}

}  // namespace
}  // namespace tint::resolver
