summary refs log tree commit diff stats
path: root/compiler/semcall.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2018-06-16 03:51:31 +0300
committerZahary Karadjov <zahary@gmail.com>2018-06-16 16:46:32 +0300
commit31651ecd613b7fddea037cb0cc7d433bec6c902d (patch)
tree8e6560fa2fb73642857be1edeff6d72c5fba49d8 /compiler/semcall.nim
parente719f211c634d2be7b5ae118db7051a2382a8e3e (diff)
downloadNim-31651ecd613b7fddea037cb0cc7d433bec6c902d.tar.gz
allow referencing other parameters in default parameter values
fix #7756
fix #1201
fix #7000
fix #3002
fix #1046
Diffstat (limited to 'compiler/semcall.nim')
-rw-r--r--compiler/semcall.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 0de22cfb3..67fe99232 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -402,7 +402,9 @@ proc updateDefaultParams(call: PNode) =
   for i in countdown(call.len - 1, 1):
     if nfDefaultParam notin call[i].flags:
       return
-    call[i] = calleeParams[i].sym.ast
+    let def = calleeParams[i].sym.ast
+    if nfDefaultRefsParam in def.flags: call.flags.incl nfDefaultRefsParam
+    call[i] = def
 
 proc semResolvedCall(c: PContext, x: TCandidate,
                      n: PNode, flags: TExprFlags): PNode =