Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Fedorin <[email protected]>
  • Loading branch information
DanilaFe committed Jan 2, 2025
1 parent a8c6628 commit 8f2cdbe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions frontend/test/resolution/testVarArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,24 @@ var c = fn(y=5.0, "hello", 1, "test", 3.0);

}

// regression test for a bug in which two fucntions (see body of the test)
// are incorrectly considered ambiguous. The vararg-based function is less
// specific than the 'integral'-based function since the latter constraints
// the type more.
static void testGenericInstantiationDisambiguation() {
Context* context = buildStdContext();
auto program =
R"""(
proc foo(x...) do return 1.0;
proc foo(x: integral) do return 1;
var x = foo(10);
)""";

auto qt = resolveTypeOfX(context, program);
CHPL_ASSERT(qt->isIntType());
}

//
// TODO: test where-clauses:
//
Expand Down Expand Up @@ -864,6 +882,7 @@ int main(int argc, char** argv) {
testConcrete();
testCount();
testAlignment();
testGenericInstantiationDisambiguation();

printf("\nAll tests passed successfully.\n");

Expand Down

0 comments on commit 8f2cdbe

Please sign in to comment.