From 4d388294bd4f64ec35cec1d0fb2cb30682bf7696 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 23 Sep 2024 10:36:51 -0700 Subject: [PATCH] Test resolving parenless call within param loop Signed-off-by: Anna Rift --- frontend/test/resolution/testMethodCalls.cpp | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/frontend/test/resolution/testMethodCalls.cpp b/frontend/test/resolution/testMethodCalls.cpp index e581697ede0..f02fb2a1c77 100644 --- a/frontend/test/resolution/testMethodCalls.cpp +++ b/frontend/test/resolution/testMethodCalls.cpp @@ -738,6 +738,34 @@ static void test14b() { assert(guard.realizeErrors() == 2); } +static void test15() { + // Test resolving parenless calls from within param for loop. + Context ctx; + Context* context = &ctx; + ErrorGuard guard(context); + + std::string program = R"""( + class Foo { + proc asdf do return 3; + + proc doSomething() { + for param i in 0..2 do + return asdf; + } + } + + var f = new Foo(); + var x = f.doSomething(); + )"""; + + QualifiedType initType = resolveTypeOfXInit(context, program); + assert(initType.type()); + assert(initType.type()->isIntType()); + + assert(guard.realizeErrors() == 0); +} + + int main() { test1(); test2(); @@ -754,6 +782,7 @@ int main() { test13(); test14(); test14b(); + test15(); return 0; }