summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/manual.txt21
-rw-r--r--lib/pure/osproc.nim95
-rw-r--r--tests/parser/tstrongspaces.nim52
-rw-r--r--todo.txt1
4 files changed, 118 insertions, 51 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index c85998741..ab1badaf3 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -79,8 +79,21 @@ program execution. Unless explicitly classified, an error is a static error.
 
 A `checked runtime error`:idx: is an error that the implementation detects
 and reports at runtime. The method for reporting such errors is via *raising
-exceptions*. However, the implementation provides a means to disable these
-runtime checks. See the section pragmas_ for details.
+exceptions* or *dying with a fatal error*. However, the implementation 
+provides a means to disable these runtime checks. See the section pragmas_
+for details. 
+
+Wether a checked runtime error results in an exception or in a fatal error at
+runtime is implementation specific. Thus the following program is always
+invalid:
+
+.. code-block:: nimrod
+  var a: array[0..1, char]
+  let i = 5
+  try:
+    a[i] = 'N'
+  except EInvalidIndex:
+    echo "invalid index"
 
 An `unchecked runtime error`:idx: is an error that is not guaranteed to be
 detected, and can cause the subsequent behavior of the computation to
@@ -522,7 +535,7 @@ Strong spaces
 The number of spaces preceeding a non-keyword operator affects precedence
 if the experimental parser directive ``#!strongSpaces`` is used. Indentation
 is not used to determine the number of spaces. If 2 or more operators have the
-same number of preceeding spaces the precedence table applies, so ``1 + 3 * 4``
+same number of preceding spaces the precedence table applies, so ``1 + 3 * 4``
 is still parsed as ``1 + (3 * 4)``, but ``1+3 * 4`` is parsed as ``(1+3) * 4``:
 
 .. code-block:: nimrod
@@ -3487,7 +3500,7 @@ Declarative type classes are written in the following form:
       c.len is ordinal
       items(c) is iterator
       for value in c:
-        value.type is T
+        type(value) is T
 
 The type class will be matched if:
 
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 582b3c960..5d6848565 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -606,7 +606,8 @@ elif not defined(useNimRtl):
     optionPoParentStreams: bool
     optionPoStdErrToStdOut: bool
 
-  proc startProcessAuxSpawn(data: TStartProcessData): TPid {.tags: [FExecIO, FReadEnv].}
+  when not defined(useFork):
+    proc startProcessAuxSpawn(data: TStartProcessData): TPid {.tags: [FExecIO, FReadEnv].}
   proc startProcessAuxFork(data: TStartProcessData): TPid {.tags: [FExecIO, FReadEnv].}
   {.push stacktrace: off, profiler: off.}
   proc startProcessAfterFork(data: ptr TStartProcessData) {.
@@ -664,7 +665,8 @@ elif not defined(useNimRtl):
     data.workingDir = workingDir
 
 
-    when defined(posix_spawn) and not defined(useFork) and not defined(useClone) and not defined(linux):
+    when defined(posix_spawn) and not defined(useFork) and 
+        not defined(useClone) and not defined(linux):
       pid = startProcessAuxSpawn(data)
     else:
       pid = startProcessAuxFork(data)
@@ -694,55 +696,56 @@ elif not defined(useNimRtl):
       discard close(pStdin[readIdx])
       discard close(pStdout[writeIdx])
 
-  proc startProcessAuxSpawn(data: TStartProcessData): TPid =
-    var attr: Tposix_spawnattr
-    var fops: Tposix_spawn_file_actions
-
-    template chck(e: expr) =
-      if e != 0'i32: osError(osLastError())
-
-    chck posix_spawn_file_actions_init(fops)
-    chck posix_spawnattr_init(attr)
-
-    var mask: Tsigset
-    chck sigemptyset(mask)
-    chck posix_spawnattr_setsigmask(attr, mask)
-    chck posix_spawnattr_setpgroup(attr, 0'i32)
-
-    chck posix_spawnattr_setflags(attr, POSIX_SPAWN_USEVFORK or
-                                        POSIX_SPAWN_SETSIGMASK or
-                                        POSIX_SPAWN_SETPGROUP)
-
-    if not data.optionPoParentStreams:
-      chck posix_spawn_file_actions_addclose(fops, data.pStdin[writeIdx])
-      chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
-      chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
-      chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
-      chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
-      if data.optionPoStdErrToStdOut:
-        chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
+  when not defined(useFork):
+    proc startProcessAuxSpawn(data: TStartProcessData): TPid =
+      var attr: Tposix_spawnattr
+      var fops: Tposix_spawn_file_actions
+
+      template chck(e: expr) =
+        if e != 0'i32: osError(osLastError())
+
+      chck posix_spawn_file_actions_init(fops)
+      chck posix_spawnattr_init(attr)
+
+      var mask: Tsigset
+      chck sigemptyset(mask)
+      chck posix_spawnattr_setsigmask(attr, mask)
+      chck posix_spawnattr_setpgroup(attr, 0'i32)
+
+      chck posix_spawnattr_setflags(attr, POSIX_SPAWN_USEVFORK or
+                                          POSIX_SPAWN_SETSIGMASK or
+                                          POSIX_SPAWN_SETPGROUP)
+
+      if not data.optionPoParentStreams:
+        chck posix_spawn_file_actions_addclose(fops, data.pStdin[writeIdx])
+        chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
+        chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
+        chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
+        chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
+        if data.optionPoStdErrToStdOut:
+          chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
+        else:
+          chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
+
+      var res: cint
+      # FIXME: chdir is global to process
+      if data.workingDir.len > 0:
+        setCurrentDir($data.workingDir)
+      var pid: TPid
+
+      if data.optionPoUsePath:
+        res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
       else:
-        chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
-
-    var res: cint
-    # FIXME: chdir is global to process
-    if data.workingDir.len > 0:
-      setCurrentDir($data.workingDir)
-    var pid: TPid
-
-    if data.optionPoUsePath:
-      res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
-    else:
-      res = posix_spawn(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
+        res = posix_spawn(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
 
-    discard posix_spawn_file_actions_destroy(fops)
-    discard posix_spawnattr_destroy(attr)
-    chck res
-    return pid
+      discard posix_spawn_file_actions_destroy(fops)
+      discard posix_spawnattr_destroy(attr)
+      chck res
+      return pid
 
   proc startProcessAuxFork(data: TStartProcessData): TPid =
     if pipe(data.pErrorPipe) != 0:
-        osError(osLastError())
+      osError(osLastError())
 
     finally:
       discard close(data.pErrorPipe[readIdx])
diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim
new file mode 100644
index 000000000..91506daf0
--- /dev/null
+++ b/tests/parser/tstrongspaces.nim
@@ -0,0 +1,52 @@
+#! strongSpaces
+
+discard """
+  output: '''35
+77
+(Field0: 1, Field1: 2, Field2: 2)
+ha
+true
+tester args
+all
+all args
+'''
+"""
+
+echo 2+5 * 5
+
+let foo = 77
+echo $foo
+
+echo (1, 2, 2)
+
+template `&`(a, b: int): expr = a and b
+template `|`(a, b: int): expr = a - b
+template `++`(a, b: int): expr = a + b == 8009
+
+when true:
+  let b = 66
+  let c = 90
+  let bar = 8000
+  if foo+4 * 4 == 8 and b&c | 9  ++
+      bar:
+    echo "ho"
+  else:
+    echo "ha"
+
+  let booA = foo+4 * 4  -  b&c | 9  +
+      bar
+  # is parsed as
+  let booB = ((foo+4)*4) - ((b&c) | 9) + bar
+
+  echo booA == booB
+
+
+template `|`(a, b): expr = (if a.len > 0: a else: b)
+
+const
+  tester = "tester"
+  args = "args"
+
+echo tester & " " & args|"all"
+echo "all"  |  tester & " " & args
+echo "all"|tester & " " & args
diff --git a/todo.txt b/todo.txt
index 51f883d1d..3b085ac91 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,7 +1,6 @@
 version 0.9.4
 =============
 
-- make testament produce full JSON information
 - fix gensym capture bug
 - vm
   - at least try to get the basic type zoo ops right