From 5cecd81a05de0f3db3d77407e70a33d65bd9df2c Mon Sep 17 00:00:00 2001 From: metagn Date: Wed, 8 May 2024 18:35:26 +0300 Subject: [PATCH] fix semFinishOperands for bracket expressions [backport:2.0] (#23571) fixes #23568, fixes #23310 In #23091 `semFinishOperands` was changed to not be called for `mArrGet` and `mArrPut`, presumably in preparation for #23188 (not sure why it was needed in #23091, maybe they got mixed together), since the compiler handles these later and needs the first argument to not be completely "typed" since brackets can serve as explicit generic instantiations in which case the first argument would have to be an unresolved generic proc (not accepted by `finishOperand`). In this PR we just make it so `mArrGet` and `mArrPut` specifically skip calling `finishOperand` on the first argument. This way the generic arguments in the explicit instantiation get typed, but not the unresolved generic proc. (cherry picked from commit 09bd9d0b19a69a56b875eff6e6d119aaf67664fd) --- compiler/semexprs.nim | 15 ++++++++------- tests/generics/tnestedissues.nim | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 tests/generics/tnestedissues.nim diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 8b22555ae2..a179c68d7b 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1012,10 +1012,14 @@ proc finishOperand(c: PContext, a: PNode): PNode = localError(c.config, a.info, err) considerGenSyms(c, result) -proc semFinishOperands(c: PContext; n: PNode) = +proc semFinishOperands(c: PContext; n: PNode; isBracketExpr = false) = # this needs to be called to ensure that after overloading resolution every - # argument has been sem'checked: - for i in 1..