This commit is contained in:
Araq 2020-03-10 10:39:43 +01:00 • committed by Andreas Rumpf
commit 861a5340fe
7 changed files with 37 additions and 7 deletions

View file

@ -40,6 +40,10 @@
- The `{.dynlib.}` pragma is now required for exporting symbols when making - The `{.dynlib.}` pragma is now required for exporting symbols when making
shared objects on POSIX and macOS, which make it consistent with the behavior shared objects on POSIX and macOS, which make it consistent with the behavior
on Windows. on Windows.
- The compiler is now more strict about type conversions concerning proc
types: Type conversions cannot be used to hide `.raise` effects or side
effects, instead a `cast` must be used. With the flag `--useVersion:1.0` the
old behaviour is emulated.
## Library additions ## Library additions

View file

@ -592,8 +592,11 @@ const
tfReturnsNew* = tfInheritable tfReturnsNew* = tfInheritable
skError* = skUnknown skError* = skUnknown
# type flags that are essential for type equality: var
eqTypeFlags* = {tfIterator, tfNotNil, tfVarIsPtr} eqTypeFlags* = {tfIterator, tfNotNil, tfVarIsPtr, tfGcSafe, tfNoSideEffect}
## type flags that are essential for type equality.
## This is now a variable because for emulation of version:1.0 we
## might exclude {tfGcSafe, tfNoSideEffect}.
type type
TMagic* = enum # symbols that require compiler magic: TMagic* = enum # symbols that require compiler magic:

View file

@ -32,6 +32,7 @@ import
pathutils, strtabs pathutils, strtabs
from incremental import nimIncremental from incremental import nimIncremental
from ast import eqTypeFlags, tfGcSafe, tfNoSideEffect
# but some have deps to imported modules. Yay. # but some have deps to imported modules. Yay.
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc") bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
@ -869,10 +870,11 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "1.0": of "1.0":
defineSymbol(conf.symbols, "NimMajor", "1") defineSymbol(conf.symbols, "NimMajor", "1")
defineSymbol(conf.symbols, "NimMinor", "0") defineSymbol(conf.symbols, "NimMinor", "0")
# always be compatible with 1.0.2 for now: # always be compatible with 1.0.100:
defineSymbol(conf.symbols, "NimPatch", "2") defineSymbol(conf.symbols, "NimPatch", "100")
# old behaviors go here: # old behaviors go here:
defineSymbol(conf.symbols, "nimOldRelativePathBehavior") defineSymbol(conf.symbols, "nimOldRelativePathBehavior")
ast.eqTypeFlags.excl {tfGcSafe, tfNoSideEffect}
else: else:
localError(conf, info, "unknown Nim version; currently supported values are: {1.0}") localError(conf, info, "unknown Nim version; currently supported values are: {1.0}")
of "benchmarkvm": of "benchmarkvm":

View file

@ -278,7 +278,7 @@ when defined(windows) or defined(nimdoc):
result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1) result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1)
result.handles = initSet[AsyncFD]() result.handles = initSet[AsyncFD]()
result.timers.newHeapQueue() result.timers.newHeapQueue()
result.callbacks = initDeque[proc ()](64) result.callbacks = initDeque[proc () {.closure, gcsafe.}](64)
var gDisp{.threadvar.}: owned PDispatcher ## Global dispatcher var gDisp{.threadvar.}: owned PDispatcher ## Global dispatcher

View file

@ -46,7 +46,7 @@ template createCb(retFutureSym, iteratorNameSym,
else: else:
{.gcsafe.}: {.gcsafe.}:
{.push hint[ConvFromXtoItselfNotNeeded]: off.} {.push hint[ConvFromXtoItselfNotNeeded]: off.}
next.callback = (proc() {.closure, gcsafe.})(identName) next.callback = cast[proc() {.closure, gcsafe.}](identName)
{.pop.} {.pop.}
except: except:
futureVarCompletions futureVarCompletions

View file

@ -26,7 +26,7 @@ proc failedAssertImpl*(msg: string) {.raises: [], tags: [].} =
# by ``assert``. # by ``assert``.
type Hide = proc (msg: string) {.noinline, raises: [], noSideEffect, type Hide = proc (msg: string) {.noinline, raises: [], noSideEffect,
tags: [].} tags: [].}
Hide(raiseAssert)(msg) cast[Hide](raiseAssert)(msg)
template assertImpl(cond: bool, msg: string, expr: string, enabled: static[bool]) = template assertImpl(cond: bool, msg: string, expr: string, enabled: static[bool]) =
when enabled: when enabled:

View file

@ -0,0 +1,21 @@
discard """
output: ''''''
cmd: "nim c --gc:arc $file"
"""
# bug #13519
var unrelated: seq[proc() {.closure, gcsafe.}]
unrelated.add proc () =
echo "gcsafe"
import tables, sequtils
let t = newTable[int, proc()]()
type
MyProc = proc() {.closure.}
var result: seq[MyProc] = @[]
for x in t.values:
result.add(x)