summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/patterns.nim31
-rwxr-xr-xcompiler/types.nim4
2 files changed, 13 insertions, 22 deletions
diff --git a/compiler/patterns.nim b/compiler/patterns.nim
index ceadfe350..110fae08a 100644
--- a/compiler/patterns.nim
+++ b/compiler/patterns.nim
@@ -23,9 +23,6 @@ type
   PPatternContext = var TPatternContext
 
 proc matches(c: PPatternContext, p, n: PNode): bool
-proc checkConstraints(c: PPatternContext, p, n: PNode): bool =
-  # XXX create a new mapping here? --> need use cases
-  result = matches(c, p, n)
 
 proc canonKind(n: PNode): TNodeKind =
   ## nodekind canonilization for pattern matching
@@ -85,34 +82,28 @@ proc bindOrCheck(c: PPatternContext, param: PSym, n: PNode): bool =
   if pp != nil:
     # check if we got the same pattern (already unified):
     result = sameTrees(pp, n) #matches(c, pp, n)
-  elif checkTypes(c, param, n) and 
-      (param.ast == nil or checkConstraints(c, param.ast, n)):
+  elif n.kind == nkArgList or checkTypes(c, param, n):
     IdNodeTablePutLazy(c.mapping, param, n)
     result = true
 
 proc matchStar(c: PPatternContext, p, n: PNode): bool =
   # match ``op*param``
-  # this is quite hard: 
-  # match against: f(a, ..., f(b, c, f(...)))
-  # we have different semantics if there is a choice as left operand:
 
   proc matchStarAux(c: PPatternContext, op, n, arglist: PNode) =
     if n.kind in nkCallKinds and matches(c, op, n.sons[0]):
-      for i in 1..sonsLen(n)-1: matchStarAux(c, op, n.sons[i], arglist)
+      for i in 1..sonsLen(n)-1:
+        matchStarAux(c, op, n[i], arglist)    
+    elif n.kind == nkHiddenStdConv and n.sons[1].kind == nkBracket:
+      let n = n.sons[1]
+      for i in 0.. <n.len: matchStarAux(c, op, n[i], arglist)
     else:
       add(arglist, n)
-
+    
   if n.kind notin nkCallKinds: return false
-  if p.sons[0].kind != nkPattern:
-    if matches(c, p.sons[0], n.sons[0]):
-      var arglist = newNodeI(nkArgList, n.info)
-      arglist.typ = p.sons[1].sym.typ
-      matchStarAux(c, p.sons[0], n, arglist)
-      result = bindOrCheck(c, p.sons[1].sym, arglist)
-  else:
-    # well it matches somehow ...
-    if matches(c, p.sons[0], n.sons[0]):
-      result = bindOrCheck(c, p.sons[1].sym, n)
+  if matches(c, p.sons[1], n.sons[0]):
+    var arglist = newNodeI(nkArgList, n.info)
+    matchStarAux(c, p.sons[1], n, arglist)
+    result = bindOrCheck(c, p.sons[2].sym, arglist)
 
 proc matches(c: PPatternContext, p, n: PNode): bool =
   # hidden conversions (?)
diff --git a/compiler/types.nim b/compiler/types.nim
index 8a01e6c76..bf7655ebb 100755
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -432,12 +432,12 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
     add(result, ']')
   of tyTypeDesc:
     if t.sons.len == 0: result = "typedesc"
-    else: result = "typedesc{" & constraintsToStr(t) & "}"
+    else: result = "typedesc[" & constraintsToStr(t) & "]"
   of tyTypeClass:
     result = constraintsToStr(t)
   of tyExpr:
     if t.sons.len == 0: result = "expr"
-    else: result = "expr{" & constraintsToStr(t) & "}"
+    else: result = "expr[" & constraintsToStr(t) & "]"
   of tyArray: 
     if t.sons[0].kind == tyRange: 
       result = "array[" & rangeToStr(t.sons[0].n) & ", " &