summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-04-04 12:08:34 +0200
committerAraq <rumpf_a@web.de>2017-04-04 12:08:34 +0200
commit87732f797c634b9c3ee1fbb77c0ed0c416d16db6 (patch)
treeffeb56f9f15b5e2bf7d16e155cebe89fbc0cda94
parente105c04e49bd42fdb4566a91105353eb3b218142 (diff)
downloadNim-87732f797c634b9c3ee1fbb77c0ed0c416d16db6.tar.gz
fixes #5638
-rw-r--r--compiler/semcall.nim4
-rw-r--r--tests/metatype/tcompilesregression.nim18
2 files changed, 19 insertions, 3 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 5a756c974..1089ab7db 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -250,13 +250,11 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
       if result.state in {csEmpty, csNoMatch}:
         tryOp "."
 
-    elif nfDotSetter in n.flags:
-      internalAssert f.kind == nkIdent and n.sonsLen == 3
+    elif nfDotSetter in n.flags and f.kind == nkIdent and n.len == 3:
       let calleeName = newStrNode(nkStrLit,
         f.ident.s[0..f.ident.s.len-2]).withInfo(n.info)
       let callOp = newIdentNode(getIdent".=", n.info)
       n.sons[0..1] = [callOp, n[1], calleeName]
-      #excl(n.flags, nfDotSetter)
       orig.sons[0..1] = [callOp, orig[1], calleeName]
       pickBest(callOp)
 
diff --git a/tests/metatype/tcompilesregression.nim b/tests/metatype/tcompilesregression.nim
new file mode 100644
index 000000000..489cd06d6
--- /dev/null
+++ b/tests/metatype/tcompilesregression.nim
@@ -0,0 +1,18 @@
+discard """
+  output: '''ok'''
+"""
+
+# bug #5638
+
+type X = object
+  a_impl: int
+
+proc a(x: X): int =
+  x.a_impl
+
+var x: X
+assert(not compiles((block:
+  x.a = 1
+)))
+
+echo "ok"