diff --git a/frontend/test/resolution/testTuples.cpp b/frontend/test/resolution/testTuples.cpp index 0ca455dd0df3..87684136b4a4 100644 --- a/frontend/test/resolution/testTuples.cpp +++ b/frontend/test/resolution/testTuples.cpp @@ -971,6 +971,32 @@ static void test20() { } } +static void test21() { + // Ensure that (type int, type int) tuples in type expression are properly + // handled when they are specifying the type of var or const variable. + + Context ctx; + Context* context = &ctx; + auto program = R"""( + var x: 2*int = (7,3); + const y: 2*int = (7,3); + var x2: 2*int; + const y2: 2*int; + + param firstMatch = x.type == x2.type; + param secondMatch = y.type == y2.type; + )"""; + + auto vars = resolveTypesOfVariables(context, program, + {"x", "y", "x2", "y2", "firstMatch", "secondMatch"}); + assert(vars["x"].type()->isTupleType()); + assert(vars["y"].type()->isTupleType()); + assert(vars["x2"].type()->isTupleType()); + assert(vars["y2"].type()->isTupleType()); + ensureParamBool(vars["firstMatch"], true); + ensureParamBool(vars["secondMatch"], true); +} + int main() { test1(); @@ -998,5 +1024,6 @@ int main() { testTupleGeneric(); test20(); + test21(); return 0; }