From 7e858545c1d46c079d0c5ccda344b94b3512cd39 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Wed, 25 Sep 2024 13:21:10 -0700 Subject: [PATCH] Fix 'tag' formal position for non-methods Signed-off-by: Anna Rift --- frontend/lib/resolution/Resolver.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/lib/resolution/Resolver.cpp b/frontend/lib/resolution/Resolver.cpp index 5f15a95a220..d61be4cae20 100644 --- a/frontend/lib/resolution/Resolver.cpp +++ b/frontend/lib/resolution/Resolver.cpp @@ -4850,12 +4850,15 @@ bool Resolver::enter(const IndexableLoop* loop) { auto& iterandRE = byPostorder.byAst(iterand); auto& MSC = iterandRE.mostSpecific(); auto fn = MSC.only() ? MSC.only().fn() : nullptr; - const unsigned int tagPos = 1; - if (fn && fn->isIterator() && - fn->numFormals() >= (tagPos + 1) && - fn->formalType(tagPos).type() == EnumType::getIterKindType(context)) { - if (!loopRequiresParallel) { - m = IterDetails::ANY; + if (fn && fn->isIterator()) { + const unsigned int tagPos = + fn->isMethod() ? 1 : 0; // offset for 'this' + if (fn->numFormals() > tagPos && + fn->formalType(tagPos).type() == + EnumType::getIterKindType(context)) { + if (!loopRequiresParallel) { + m = IterDetails::ANY; + } } } }