summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-12-23 20:05:08 +0100
committerAraq <rumpf_a@web.de>2011-12-23 20:05:08 +0100
commit76f91b90e2a411a6d2ca82f075f55abe63d8f6a5 (patch)
treea5406ca547c04dbd48e99a806474b2399202afbf
parent6260757a2a760c05881c01ea9051ba245d06778d (diff)
downloadNim-76f91b90e2a411a6d2ca82f075f55abe63d8f6a5.tar.gz
bugfix: compiler errors for explicit initialization of thread local variables; os.nim does not rely on it anymore
-rwxr-xr-xcompiler/msgs.nim4
-rwxr-xr-xcompiler/semstmts.nim3
-rwxr-xr-xlib/pure/os.nim6
3 files changed, 9 insertions, 4 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index ff153c1c2..08bf74406 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -92,7 +92,8 @@ type
     errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, 
     errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, 
     errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, 
-    errXhasSideEffects, errIteratorExpected, errLetNeedsInit, errWrongSymbolX,
+    errXhasSideEffects, errIteratorExpected, errLetNeedsInit,
+    errThreadvarCannotInit, errWrongSymbolX,
     errUser,
     warnCannotOpenFile, 
     warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, 
@@ -321,6 +322,7 @@ const
     errXhasSideEffects: "\'$1\' can have side effects", 
     errIteratorExpected: "iterator within for loop context expected",
     errLetNeedsInit: "'let' symbol requires an initialization",
+    errThreadvarCannotInit: "a thread var cannot be initialized explicitly",
     errWrongSymbolX: "usage of \'$1\' is a user-defined error", 
     errUser: "$1", 
     warnCannotOpenFile: "cannot open \'$1\' [CannotOpenFile]",
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 0317db849..64b0f5339 100755
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -269,7 +269,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
       if def != nil and def.kind != nkEmpty:
         # this is only needed for the evaluation pass:
         v.ast = def
-      if a.kind != nkVarTuple: 
+        if sfThread in v.flags: LocalError(def.info, errThreadvarCannotInit)
+      if a.kind != nkVarTuple:
         v.typ = typ
         b = newNodeI(nkIdentDefs, a.info)
         addSon(b, newSymNode(v))
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 32a248f15..f96998831 100755
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -694,8 +694,8 @@ proc execShellCmd*(command: string): int {.rtl, extern: "nos$1".} =
 # iterator depends on ``environment``.
 
 var
-  envComputed {.threadvar.}: bool = false
-  environment {.threadvar.}: seq[string] = @[]
+  envComputed {.threadvar.}: bool
+  environment {.threadvar.}: seq[string]
 
 when defined(windows):
   # because we support Windows GUI applications, things get really
@@ -705,6 +705,7 @@ when defined(windows):
 
   proc getEnvVarsC() =
     if not envComputed:
+      environment = @[]
       var
         env = getEnvironmentStringsA()
         e = env
@@ -738,6 +739,7 @@ else:
   proc getEnvVarsC() =
     # retrieves the variables of char** env of C's main proc
     if not envComputed:
+      environment = @[]
       when useNSGetEnviron:
         var gEnv = NSGetEnviron()[]
       var i = 0