From dd7ebb2c95a47745c12a9bb8274b2362f96afea1 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 2 Apr 2017 16:48:23 -0500 Subject: [PATCH 1/3] fixup! support for the Genode OS framework (#5653) Allocate thread metadata at createThread. --- lib/genode_cpp/threads.h | 1 - lib/system/threads.nim | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/genode_cpp/threads.h b/lib/genode_cpp/threads.h index a1cd61cd2c..043f808f10 100644 --- a/lib/genode_cpp/threads.h +++ b/lib/genode_cpp/threads.h @@ -13,7 +13,6 @@ #define _GENODE_CPP__THREAD_H_ #include -#include #include namespace Nim { struct SysThread; } diff --git a/lib/system/threads.nim b/lib/system/threads.nim index 4855a2b93f..7743fffff5 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -593,6 +593,8 @@ elif defined(genode): proc createThread*[TArg](t: var Thread[TArg], tp: proc (arg: TArg) {.thread, nimcall.}, param: TArg) = + t.core = cast[PGcThread](allocShared0(sizeof(GcThread))) + when TArg isnot void: t.data = param t.dataFn = tp when hasSharedHeap: t.stackSize = ThreadStackSize From e105c04e49bd42fdb4566a91105353eb3b218142 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 4 Apr 2017 10:43:54 +0200 Subject: [PATCH 2/3] revert PR #5638 because it breaks code --- compiler/semcall.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 2dd115b1bc..5a756c9741 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -155,7 +155,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): renderTree(n[err.unmatchedVarParam]) & "' is immutable\n") for diag in err.diagnostics: add(candidates, diag & "\n") - + result = (prefer, candidates) proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) = @@ -256,7 +256,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode, 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) + #excl(n.flags, nfDotSetter) orig.sons[0..1] = [callOp, orig[1], calleeName] pickBest(callOp) From 87732f797c634b9c3ee1fbb77c0ed0c416d16db6 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 4 Apr 2017 12:08:34 +0200 Subject: [PATCH 3/3] fixes #5638 --- compiler/semcall.nim | 4 +--- tests/metatype/tcompilesregression.nim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/metatype/tcompilesregression.nim diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 5a756c9741..1089ab7db8 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 0000000000..489cd06d67 --- /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"