summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-04-07 17:30:15 +0300
committerZahary Karadjov <zahary@gmail.com>2017-04-07 19:28:52 +0300
commitfb3ff64450526f532492c04c6cc02469cfb3d633 (patch)
tree45ac4e5e3a3e744f05564f90d1e4fa5a81a05cbd /compiler
parenteb635d9ccf4abb9a003808ed1ddce889ecd982ef (diff)
downloadNim-fb3ff64450526f532492c04c6cc02469cfb3d633.tar.gz
fix #5642
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--compiler/semexprs.nim2
-rw-r--r--compiler/semfields.nim5
3 files changed, 6 insertions, 3 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index b03f7c5aa..15bd7f2e0 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -756,7 +756,7 @@ proc genRecordField(p: BProc, e: PNode, d: var TLoc) =
   genRecordFieldAux(p, e, d, a)
   var r = rdLoc(a)
   var f = e.sons[1].sym
-  let ty = skipTypes(a.t, abstractInst)
+  let ty = skipTypes(a.t, abstractInst + tyUserTypeClasses)
   if ty.kind == tyTuple:
     # we found a unique tuple type which lacks field information
     # so we use Field$i
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 316cf55c8..1b2222b2e 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1155,6 +1155,8 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
     ty = n.sons[0].typ
     return nil
   ty = skipTypes(ty, {tyGenericInst, tyVar, tyPtr, tyRef, tyAlias})
+  if ty.kind in tyUserTypeClasses and ty.isResolvedUserTypeClass:
+    ty = ty.lastSon
   while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct})
   var check: PNode = nil
   if ty.kind == tyObject:
diff --git a/compiler/semfields.nim b/compiler/semfields.nim
index 06826ef75..6002705b3 100644
--- a/compiler/semfields.nim
+++ b/compiler/semfields.nim
@@ -121,12 +121,13 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode =
     localError(n.info, errWrongNumberOfVariables)
     return result
 
-  var tupleTypeA = skipTypes(call.sons[1].typ, abstractVar-{tyTypeDesc})
+  const skippedTypesForFields = abstractVar - {tyTypeDesc} + tyUserTypeClasses
+  var tupleTypeA = skipTypes(call.sons[1].typ, skippedTypesForFields)
   if tupleTypeA.kind notin {tyTuple, tyObject}:
     localError(n.info, errGenerated, "no object or tuple type")
     return result
   for i in 1..call.len-1:
-    var tupleTypeB = skipTypes(call.sons[i].typ, abstractVar-{tyTypeDesc})
+    var tupleTypeB = skipTypes(call.sons[i].typ, skippedTypesForFields)
     if not sameType(tupleTypeA, tupleTypeB):
       typeMismatch(call.sons[i].info, tupleTypeA, tupleTypeB)