summary refs log tree commit diff stats
path: root/compiler/ast.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-08-16 01:22:21 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-16 01:22:21 +0200
commite4c759fbffae852b938a076de38ba2df4eab6afa (patch)
treef793335b31a460cae2966dd407ec934671ecc9ee /compiler/ast.nim
parentb78114ce507757cd79649212bd17dc86965aa4ef (diff)
parent531c66d1ec583a35d8d6bc637c94457fcd87a8e3 (diff)
downloadNim-e4c759fbffae852b938a076de38ba2df4eab6afa.tar.gz
Merge branch 'devel' into araq-misc
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r--compiler/ast.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index e294eccc2..01e70ce75 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1680,6 +1680,14 @@ proc skipStmtList*(n: PNode): PNode =
   else:
     result = n
 
+proc toVar*(typ: PType): PType =
+  ## If ``typ`` is not a tyVar then it is converted into a `var <typ>` and
+  ## returned. Otherwise ``typ`` is simply returned as-is.
+  result = typ
+  if typ.kind != tyVar:
+    result = newType(tyVar, typ.owner)
+    rawAddSon(result, typ)
+
 proc toRef*(typ: PType): PType =
   ## If ``typ`` is a tyObject then it is converted into a `ref <typ>` and
   ## returned. Otherwise ``typ`` is simply returned as-is.