From b28c7d434b16ebd9cc33ef1d6b267b49660153ba Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 20 Aug 2018 16:54:13 +0200 Subject: [PATCH] Update all the default parameters after an instantiation (#8689) The old implementation relied on the (now?) wrong assumption that default-valued parameters can only be placed after the required ones. Fixes #8683 --- compiler/semcall.nim | 11 +++++------ tests/proc/t8683.nim | 11 +++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 tests/proc/t8683.nim diff --git a/compiler/semcall.nim b/compiler/semcall.nim index ef452fcdc..dc71f2567 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -399,12 +399,11 @@ proc updateDefaultParams(call: PNode) = # the default params with `nfDefaultParam` and `instantiateProcType` # computes correctly the default values for each instantiation. let calleeParams = call[0].sym.typ.n - for i in countdown(call.len - 1, 1): - if nfDefaultParam notin call[i].flags: - return - let def = calleeParams[i].sym.ast - if nfDefaultRefsParam in def.flags: call.flags.incl nfDefaultRefsParam - call[i] = def + for i in 1..