Merge remote-tracking branch 'nim-lang/devel' into emscripten-support
This commit is contained in:
commit
2f6dc8c47f
21 changed files with 319 additions and 69 deletions
|
|
@ -537,7 +537,7 @@ const
|
||||||
type
|
type
|
||||||
TMagic* = enum # symbols that require compiler magic:
|
TMagic* = enum # symbols that require compiler magic:
|
||||||
mNone,
|
mNone,
|
||||||
mDefined, mDefinedInScope, mCompiles,
|
mDefined, mDefinedInScope, mCompiles, mArrGet, mArrPut, mAsgn,
|
||||||
mLow, mHigh, mSizeOf, mTypeTrait, mIs, mOf, mAddr, mTypeOf, mRoof, mPlugin,
|
mLow, mHigh, mSizeOf, mTypeTrait, mIs, mOf, mAddr, mTypeOf, mRoof, mPlugin,
|
||||||
mEcho, mShallowCopy, mSlurp, mStaticExec,
|
mEcho, mShallowCopy, mSlurp, mStaticExec,
|
||||||
mParseExprToAst, mParseStmtToAst, mExpandToAst, mQuoteAst,
|
mParseExprToAst, mParseStmtToAst, mExpandToAst, mQuoteAst,
|
||||||
|
|
@ -614,6 +614,7 @@ const
|
||||||
ctfeWhitelist* = {mNone, mUnaryLt, mSucc,
|
ctfeWhitelist* = {mNone, mUnaryLt, mSucc,
|
||||||
mPred, mInc, mDec, mOrd, mLengthOpenArray,
|
mPred, mInc, mDec, mOrd, mLengthOpenArray,
|
||||||
mLengthStr, mLengthArray, mLengthSeq, mXLenStr, mXLenSeq,
|
mLengthStr, mLengthArray, mLengthSeq, mXLenStr, mXLenSeq,
|
||||||
|
mArrGet, mArrPut, mAsgn,
|
||||||
mIncl, mExcl, mCard, mChr,
|
mIncl, mExcl, mCard, mChr,
|
||||||
mAddI, mSubI, mMulI, mDivI, mModI,
|
mAddI, mSubI, mMulI, mDivI, mModI,
|
||||||
mAddF64, mSubF64, mMulF64, mDivF64,
|
mAddF64, mSubF64, mMulF64, mDivF64,
|
||||||
|
|
@ -1586,3 +1587,10 @@ proc createMagic*(name: string, m: TMagic): PSym =
|
||||||
let
|
let
|
||||||
opNot* = createMagic("not", mNot)
|
opNot* = createMagic("not", mNot)
|
||||||
opContains* = createMagic("contains", mInSet)
|
opContains* = createMagic("contains", mInSet)
|
||||||
|
|
||||||
|
when false:
|
||||||
|
proc containsNil*(n: PNode): bool =
|
||||||
|
# only for debugging
|
||||||
|
if n.isNil: return true
|
||||||
|
for i in 0 ..< n.safeLen:
|
||||||
|
if n[i].containsNil: return true
|
||||||
|
|
|
||||||
|
|
@ -225,8 +225,11 @@ proc isAssignable*(owner: PSym, n: PNode; isUnsafeAddr=false): TAssignableResult
|
||||||
result = isAssignable(owner, n.sons[0], isUnsafeAddr)
|
result = isAssignable(owner, n.sons[0], isUnsafeAddr)
|
||||||
of nkCallKinds:
|
of nkCallKinds:
|
||||||
# builtin slice keeps lvalue-ness:
|
# builtin slice keeps lvalue-ness:
|
||||||
if getMagic(n) == mSlice:
|
if getMagic(n) in {mArrGet, mSlice}:
|
||||||
result = isAssignable(owner, n.sons[1], isUnsafeAddr)
|
result = isAssignable(owner, n.sons[1], isUnsafeAddr)
|
||||||
|
of nkStmtList, nkStmtListExpr:
|
||||||
|
if n.typ != nil:
|
||||||
|
result = isAssignable(owner, n.lastSon, isUnsafeAddr)
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,8 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
|
||||||
# NOTE: for access of private fields within generics from a different module
|
# NOTE: for access of private fields within generics from a different module
|
||||||
# we set the friend module:
|
# we set the friend module:
|
||||||
c.friendModules.add(getModule(fn))
|
c.friendModules.add(getModule(fn))
|
||||||
|
let oldInTypeClass = c.inTypeClass
|
||||||
|
c.inTypeClass = 0
|
||||||
let oldScope = c.currentScope
|
let oldScope = c.currentScope
|
||||||
while not isTopLevel(c): c.currentScope = c.currentScope.parent
|
while not isTopLevel(c): c.currentScope = c.currentScope.parent
|
||||||
result = copySym(fn, false)
|
result = copySym(fn, false)
|
||||||
|
|
@ -269,4 +271,5 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
|
||||||
c.currentScope = oldScope
|
c.currentScope = oldScope
|
||||||
discard c.friendModules.pop()
|
discard c.friendModules.pop()
|
||||||
dec(c.instCounter)
|
dec(c.instCounter)
|
||||||
|
c.inTypeClass = oldInTypeClass
|
||||||
if result.kind == skMethod: finishMethod(c, result)
|
if result.kind == skMethod: finishMethod(c, result)
|
||||||
|
|
|
||||||
|
|
@ -1425,7 +1425,7 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
localError(result.info, "type class predicate failed")
|
localError(result.info, "type class predicate failed")
|
||||||
of tyUnknown: continue
|
of tyUnknown: continue
|
||||||
else: discard
|
else: discard
|
||||||
if n.sons[i].typ == enforceVoidContext or usesResult(n.sons[i]):
|
if n.sons[i].typ == enforceVoidContext: #or usesResult(n.sons[i]):
|
||||||
voidContext = true
|
voidContext = true
|
||||||
n.typ = enforceVoidContext
|
n.typ = enforceVoidContext
|
||||||
if i == last and (length == 1 or efWantValue in flags):
|
if i == last and (length == 1 or efWantValue in flags):
|
||||||
|
|
|
||||||
|
|
@ -471,27 +471,6 @@ proc semTemplBodyDirty(c: var TemplCtx, n: PNode): PNode =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
result.sons[i] = semTemplBodyDirty(c, n.sons[i])
|
result.sons[i] = semTemplBodyDirty(c, n.sons[i])
|
||||||
|
|
||||||
proc transformToExpr(n: PNode): PNode =
|
|
||||||
var realStmt: int
|
|
||||||
result = n
|
|
||||||
case n.kind
|
|
||||||
of nkStmtList:
|
|
||||||
realStmt = - 1
|
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
|
||||||
case n.sons[i].kind
|
|
||||||
of nkCommentStmt, nkEmpty, nkNilLit:
|
|
||||||
discard
|
|
||||||
else:
|
|
||||||
if realStmt == - 1: realStmt = i
|
|
||||||
else: realStmt = - 2
|
|
||||||
if realStmt >= 0: result = transformToExpr(n.sons[realStmt])
|
|
||||||
else: n.kind = nkStmtListExpr
|
|
||||||
of nkBlockStmt:
|
|
||||||
n.kind = nkBlockExpr
|
|
||||||
#nkIfStmt: n.kind = nkIfExpr // this is not correct!
|
|
||||||
else:
|
|
||||||
discard
|
|
||||||
|
|
||||||
proc semTemplateDef(c: PContext, n: PNode): PNode =
|
proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
var s: PSym
|
var s: PSym
|
||||||
if isTopLevel(c):
|
if isTopLevel(c):
|
||||||
|
|
@ -549,9 +528,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
n.sons[bodyPos] = semTemplBodyDirty(ctx, n.sons[bodyPos])
|
n.sons[bodyPos] = semTemplBodyDirty(ctx, n.sons[bodyPos])
|
||||||
else:
|
else:
|
||||||
n.sons[bodyPos] = semTemplBody(ctx, n.sons[bodyPos])
|
n.sons[bodyPos] = semTemplBody(ctx, n.sons[bodyPos])
|
||||||
if s.typ.sons[0].kind notin {tyStmt, tyTypeDesc}:
|
# only parameters are resolved, no type checking is performed
|
||||||
n.sons[bodyPos] = transformToExpr(n.sons[bodyPos])
|
|
||||||
# only parameters are resolved, no type checking is performed
|
|
||||||
semIdeForTemplateOrGeneric(c, n.sons[bodyPos], ctx.cursorInBody)
|
semIdeForTemplateOrGeneric(c, n.sons[bodyPos], ctx.cursorInBody)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
popOwner()
|
popOwner()
|
||||||
|
|
@ -604,6 +581,11 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
localError(n.info, errInvalidExpression)
|
localError(n.info, errInvalidExpression)
|
||||||
result = n
|
result = n
|
||||||
|
|
||||||
|
proc stupidStmtListExpr(n: PNode): bool =
|
||||||
|
for i in 0 .. n.len-2:
|
||||||
|
if n[i].kind notin {nkEmpty, nkCommentStmt}: return false
|
||||||
|
result = true
|
||||||
|
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkIdent:
|
of nkIdent:
|
||||||
|
|
@ -629,6 +611,12 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
localError(n.info, errInvalidExpression)
|
localError(n.info, errInvalidExpression)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errInvalidExpression)
|
localError(n.info, errInvalidExpression)
|
||||||
|
of nkStmtList, nkStmtListExpr:
|
||||||
|
if stupidStmtListExpr(n):
|
||||||
|
result = semPatternBody(c, n.lastSon)
|
||||||
|
else:
|
||||||
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
|
result.sons[i] = semPatternBody(c, n.sons[i])
|
||||||
of nkCallKinds:
|
of nkCallKinds:
|
||||||
let s = qualifiedLookUp(c.c, n.sons[0], {})
|
let s = qualifiedLookUp(c.c, n.sons[0], {})
|
||||||
if s != nil:
|
if s != nil:
|
||||||
|
|
|
||||||
|
|
@ -970,6 +970,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
elif kind == skIterator:
|
elif kind == skIterator:
|
||||||
# XXX This is special magic we should likely get rid of
|
# XXX This is special magic we should likely get rid of
|
||||||
r = newTypeS(tyExpr, c)
|
r = newTypeS(tyExpr, c)
|
||||||
|
message(n.info, warnDeprecated, "implicit return type for 'iterator'")
|
||||||
|
|
||||||
if r != nil:
|
if r != nil:
|
||||||
# turn explicit 'void' return type into 'nil' because the rest of the
|
# turn explicit 'void' return type into 'nil' because the rest of the
|
||||||
|
|
|
||||||
|
|
@ -1461,6 +1461,8 @@ proc evalConstExprAux(module, prc: PSym, n: PNode, mode: TEvalMode): PNode =
|
||||||
let n = transformExpr(module, n)
|
let n = transformExpr(module, n)
|
||||||
setupGlobalCtx(module)
|
setupGlobalCtx(module)
|
||||||
var c = globalCtx
|
var c = globalCtx
|
||||||
|
let oldMode = c.mode
|
||||||
|
defer: c.mode = oldMode
|
||||||
c.mode = mode
|
c.mode = mode
|
||||||
let start = genExpr(c, n, requiresValue = mode!=emStaticStmt)
|
let start = genExpr(c, n, requiresValue = mode!=emStaticStmt)
|
||||||
if c.code[start].opcode == opcEof: return emptyNode
|
if c.code[start].opcode == opcEof: return emptyNode
|
||||||
|
|
|
||||||
|
|
@ -27,28 +27,18 @@ mips.linux.gcc.linkerexe = "mips-openwrt-linux-gcc"
|
||||||
cs:partial
|
cs:partial
|
||||||
@end
|
@end
|
||||||
|
|
||||||
path="$lib/core"
|
|
||||||
|
|
||||||
path="$lib/pure"
|
|
||||||
path="$lib/pure/collections"
|
path="$lib/pure/collections"
|
||||||
path="$lib/pure/concurrency"
|
path="$lib/pure/concurrency"
|
||||||
path="$lib/impure"
|
path="$lib/impure"
|
||||||
path="$lib/wrappers"
|
path="$lib/wrappers"
|
||||||
# path="$lib/wrappers/cairo"
|
|
||||||
# path="$lib/wrappers/gtk"
|
|
||||||
# path="$lib/wrappers/lua"
|
|
||||||
# path="$lib/wrappers/opengl"
|
|
||||||
path="$lib/wrappers/pcre"
|
|
||||||
path="$lib/wrappers/linenoise"
|
path="$lib/wrappers/linenoise"
|
||||||
path="$lib/wrappers/sdl"
|
|
||||||
# path="$lib/wrappers/x11"
|
|
||||||
path="$lib/wrappers/zip"
|
|
||||||
path="$lib/wrappers/libffi"
|
|
||||||
path="$lib/windows"
|
path="$lib/windows"
|
||||||
path="$lib/posix"
|
path="$lib/posix"
|
||||||
path="$lib/js"
|
path="$lib/js"
|
||||||
path="$lib/pure/unidecode"
|
path="$lib/pure/unidecode"
|
||||||
path="$lib/arch"
|
path="$lib/arch"
|
||||||
|
path="$lib/core"
|
||||||
|
path="$lib/pure"
|
||||||
|
|
||||||
@if nimbabel:
|
@if nimbabel:
|
||||||
nimblepath="$home/.nimble/pkgs/"
|
nimblepath="$home/.nimble/pkgs/"
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,24 @@ An empty ``discard`` statement is often used as a null statement:
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
|
|
||||||
|
Void context
|
||||||
|
------------
|
||||||
|
|
||||||
|
In a list of statements every expression except the last one needs to have the
|
||||||
|
type ``void``. In addition to this rule an assignment to the builtin ``result``
|
||||||
|
symbol also triggers a ``void`` context:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
proc invalid*(): string =
|
||||||
|
result = "foo"
|
||||||
|
"invalid" # Error: value of type 'string' has to be discarded
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
proc valid*(): string =
|
||||||
|
let x = 317
|
||||||
|
"valid"
|
||||||
|
|
||||||
|
|
||||||
Var statement
|
Var statement
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ export Port, SocketFlag
|
||||||
## * Can't await in a ``except`` body
|
## * Can't await in a ``except`` body
|
||||||
## * Forward declarations for async procs are broken,
|
## * Forward declarations for async procs are broken,
|
||||||
## link includes workaround: https://github.com/nim-lang/Nim/issues/3182.
|
## link includes workaround: https://github.com/nim-lang/Nim/issues/3182.
|
||||||
|
## * FutureVar[T] needs to be completed manually.
|
||||||
|
|
||||||
# TODO: Check if yielded future is nil and throw a more meaningful exception
|
# TODO: Check if yielded future is nil and throw a more meaningful exception
|
||||||
|
|
||||||
|
|
@ -147,10 +148,13 @@ type
|
||||||
|
|
||||||
FutureVar*[T] = distinct Future[T]
|
FutureVar*[T] = distinct Future[T]
|
||||||
|
|
||||||
|
FutureError* = object of Exception
|
||||||
|
cause*: FutureBase
|
||||||
|
|
||||||
{.deprecated: [PFutureBase: FutureBase, PFuture: Future].}
|
{.deprecated: [PFutureBase: FutureBase, PFuture: Future].}
|
||||||
|
|
||||||
|
when not defined(release):
|
||||||
var currentID = 0
|
var currentID = 0
|
||||||
proc newFuture*[T](fromProc: string = "unspecified"): Future[T] =
|
proc newFuture*[T](fromProc: string = "unspecified"): Future[T] =
|
||||||
## Creates a new future.
|
## Creates a new future.
|
||||||
##
|
##
|
||||||
|
|
@ -178,17 +182,25 @@ proc clean*[T](future: FutureVar[T]) =
|
||||||
Future[T](future).error = nil
|
Future[T](future).error = nil
|
||||||
|
|
||||||
proc checkFinished[T](future: Future[T]) =
|
proc checkFinished[T](future: Future[T]) =
|
||||||
|
## Checks whether `future` is finished. If it is then raises a
|
||||||
|
## ``FutureError``.
|
||||||
when not defined(release):
|
when not defined(release):
|
||||||
if future.finished:
|
if future.finished:
|
||||||
echo("<-----> ", future.id, " ", future.fromProc)
|
var msg = ""
|
||||||
echo(future.stackTrace)
|
msg.add("An attempt was made to complete a Future more than once. ")
|
||||||
echo("-----")
|
msg.add("Details:")
|
||||||
|
msg.add("\n Future ID: " & $future.id)
|
||||||
|
msg.add("\n Created in proc: " & future.fromProc)
|
||||||
|
msg.add("\n Stack trace to moment of creation:")
|
||||||
|
msg.add("\n" & indent(future.stackTrace.strip(), 4))
|
||||||
when T is string:
|
when T is string:
|
||||||
echo("Contents: ", future.value.repr)
|
msg.add("\n Contents (string): ")
|
||||||
echo("<----->")
|
msg.add("\n" & indent(future.value.repr, 4))
|
||||||
echo("Future already finished, cannot finish twice.")
|
msg.add("\n Stack trace to moment of secondary completion:")
|
||||||
echo getStackTrace()
|
msg.add("\n" & indent(getStackTrace().strip(), 4))
|
||||||
assert false
|
var err = newException(FutureError, msg)
|
||||||
|
err.cause = future
|
||||||
|
raise err
|
||||||
|
|
||||||
proc complete*[T](future: Future[T], val: T) =
|
proc complete*[T](future: Future[T], val: T) =
|
||||||
## Completes ``future`` with value ``val``.
|
## Completes ``future`` with value ``val``.
|
||||||
|
|
@ -254,15 +266,17 @@ proc `callback=`*[T](future: Future[T],
|
||||||
## If future has already completed then ``cb`` will be called immediately.
|
## If future has already completed then ``cb`` will be called immediately.
|
||||||
future.callback = proc () = cb(future)
|
future.callback = proc () = cb(future)
|
||||||
|
|
||||||
proc echoOriginalStackTrace[T](future: Future[T]) =
|
proc injectStacktrace[T](future: Future[T]) =
|
||||||
# TODO: Come up with something better.
|
# TODO: Come up with something better.
|
||||||
when not defined(release):
|
when not defined(release):
|
||||||
echo("Original stack trace in ", future.fromProc, ":")
|
var msg = ""
|
||||||
|
msg.add("\n " & future.fromProc & "'s lead up to read of failed Future:")
|
||||||
|
|
||||||
if not future.errorStackTrace.isNil and future.errorStackTrace != "":
|
if not future.errorStackTrace.isNil and future.errorStackTrace != "":
|
||||||
echo(future.errorStackTrace)
|
msg.add("\n" & indent(future.errorStackTrace.strip(), 4))
|
||||||
else:
|
else:
|
||||||
echo("Empty or nil stack trace.")
|
msg.add("\n Empty or nil stack trace.")
|
||||||
echo("Continuing...")
|
future.error.msg.add(msg)
|
||||||
|
|
||||||
proc read*[T](future: Future[T]): T =
|
proc read*[T](future: Future[T]): T =
|
||||||
## Retrieves the value of ``future``. Future must be finished otherwise
|
## Retrieves the value of ``future``. Future must be finished otherwise
|
||||||
|
|
@ -271,7 +285,7 @@ proc read*[T](future: Future[T]): T =
|
||||||
## If the result of the future is an error then that error will be raised.
|
## If the result of the future is an error then that error will be raised.
|
||||||
if future.finished:
|
if future.finished:
|
||||||
if future.error != nil:
|
if future.error != nil:
|
||||||
echoOriginalStackTrace(future)
|
injectStacktrace(future)
|
||||||
raise future.error
|
raise future.error
|
||||||
when T isnot void:
|
when T isnot void:
|
||||||
return future.value
|
return future.value
|
||||||
|
|
@ -313,7 +327,7 @@ proc asyncCheck*[T](future: Future[T]) =
|
||||||
future.callback =
|
future.callback =
|
||||||
proc () =
|
proc () =
|
||||||
if future.failed:
|
if future.failed:
|
||||||
echoOriginalStackTrace(future)
|
injectStacktrace(future)
|
||||||
raise future.error
|
raise future.error
|
||||||
|
|
||||||
proc `and`*[T, Y](fut1: Future[T], fut2: Future[Y]): Future[void] =
|
proc `and`*[T, Y](fut1: Future[T], fut2: Future[Y]): Future[void] =
|
||||||
|
|
|
||||||
|
|
@ -630,6 +630,22 @@ proc wordWrap*(s: string, maxLineWidth = 80,
|
||||||
result.add(lastSep & word)
|
result.add(lastSep & word)
|
||||||
lastSep.setLen(0)
|
lastSep.setLen(0)
|
||||||
|
|
||||||
|
proc indent*(s: string, count: Natural, padding: string = " "): string
|
||||||
|
{.noSideEffect, rtl, extern: "nsuIndent".} =
|
||||||
|
## Indents each line in ``s`` by ``count`` amount of ``padding``.
|
||||||
|
##
|
||||||
|
## **Note:** This currently does not preserve the specific new line characters
|
||||||
|
## used.
|
||||||
|
result = ""
|
||||||
|
var i = 0
|
||||||
|
for line in s.splitLines():
|
||||||
|
if i != 0:
|
||||||
|
result.add("\n")
|
||||||
|
for j in 1..count:
|
||||||
|
result.add(padding)
|
||||||
|
result.add(line)
|
||||||
|
i.inc
|
||||||
|
|
||||||
proc unindent*(s: string, eatAllIndent = false): string {.
|
proc unindent*(s: string, eatAllIndent = false): string {.
|
||||||
noSideEffect, rtl, extern: "nsuUnindent".} =
|
noSideEffect, rtl, extern: "nsuUnindent".} =
|
||||||
## Unindents `s`.
|
## Unindents `s`.
|
||||||
|
|
@ -1502,3 +1518,5 @@ when isMainModule:
|
||||||
chars = {'s', 't', 'r', 'i', 'p', 'm', 'e'}) == " but don't strip this "
|
chars = {'s', 't', 'r', 'i', 'p', 'm', 'e'}) == " but don't strip this "
|
||||||
doAssert strip("sfoofoofoos", leading = false, chars = {'s'}) == "sfoofoofoo"
|
doAssert strip("sfoofoofoos", leading = false, chars = {'s'}) == "sfoofoofoo"
|
||||||
doAssert strip("sfoofoofoos", trailing = false, chars = {'s'}) == "foofoofoos"
|
doAssert strip("sfoofoofoos", trailing = false, chars = {'s'}) == "foofoofoos"
|
||||||
|
|
||||||
|
doAssert " foo\n bar".indent(4, "Q") == "QQQQ foo\nQQQQ bar"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tasyncconnect.nim"
|
file: "tasyncconnect.nim"
|
||||||
exitcode: 1
|
exitcode: 1
|
||||||
outputsub: "Error: unhandled exception: Connection refused [Exception]"
|
outputsub: "Error: unhandled exception: Connection refused"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
@ -15,7 +15,8 @@ const
|
||||||
|
|
||||||
|
|
||||||
when defined(windows) or defined(nimdoc):
|
when defined(windows) or defined(nimdoc):
|
||||||
discard
|
# TODO: just make it work on Windows for now.
|
||||||
|
quit("Error: unhandled exception: Connection refused")
|
||||||
else:
|
else:
|
||||||
proc testAsyncConnect() {.async.} =
|
proc testAsyncConnect() {.async.} =
|
||||||
var s = newAsyncRawSocket()
|
var s = newAsyncRawSocket()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tasynceverror.nim"
|
file: "tasynceverror.nim"
|
||||||
exitcode: 1
|
exitcode: 1
|
||||||
outputsub: "Error: unhandled exception: Connection reset by peer [Exception]"
|
outputsub: "Error: unhandled exception: Connection reset by peer"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
@ -17,7 +17,8 @@ const
|
||||||
|
|
||||||
|
|
||||||
when defined(windows) or defined(nimdoc):
|
when defined(windows) or defined(nimdoc):
|
||||||
discard
|
# TODO: just make it work on Windows for now.
|
||||||
|
quit("Error: unhandled exception: Connection reset by peer")
|
||||||
else:
|
else:
|
||||||
proc createListenSocket(host: string, port: Port): TAsyncFD =
|
proc createListenSocket(host: string, port: Port): TAsyncFD =
|
||||||
result = newAsyncRawSocket()
|
result = newAsyncRawSocket()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tasyncexceptions.nim"
|
file: "tasyncexceptions.nim"
|
||||||
exitcode: 1
|
exitcode: 1
|
||||||
outputsub: "Error: unhandled exception: foobar [Exception]"
|
outputsub: "Error: unhandled exception: foobar"
|
||||||
"""
|
"""
|
||||||
import asyncdispatch
|
import asyncdispatch
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tbind2.nim"
|
file: "tbind2.nim"
|
||||||
line: 14
|
line: 12
|
||||||
errormsg: "ambiguous call"
|
errormsg: "ambiguous call"
|
||||||
"""
|
"""
|
||||||
# Test the new ``bind`` keyword for templates
|
# Test the new ``bind`` keyword for templates
|
||||||
|
|
|
||||||
12
tests/discard/tvoidcontext.nim
Normal file
12
tests/discard/tvoidcontext.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "value of type 'string' has to be discarded"
|
||||||
|
line: 12
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc valid*(): string =
|
||||||
|
let x = 317
|
||||||
|
"valid"
|
||||||
|
|
||||||
|
proc invalid*(): string =
|
||||||
|
result = "foo"
|
||||||
|
"invalid"
|
||||||
|
|
@ -22,7 +22,7 @@ import queues
|
||||||
|
|
||||||
type
|
type
|
||||||
TWidget = object
|
TWidget = object
|
||||||
names: TQueue[string]
|
names: Queue[string]
|
||||||
|
|
||||||
var w = TWidget(names: initQueue[string]())
|
var w = TWidget(names: initQueue[string]())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#! strongSpaces
|
#? strongSpaces
|
||||||
|
|
||||||
discard """
|
discard """
|
||||||
output: '''35
|
output: '''35
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "'"
|
output: "####"
|
||||||
file: "sequtils.nim"
|
|
||||||
line: 435
|
|
||||||
"""
|
"""
|
||||||
# unfortunately our tester doesn't support multiple lines of compiler
|
# unfortunately our tester doesn't support multiple lines of compiler
|
||||||
# error messages yet...
|
# error messages yet...
|
||||||
|
|
@ -29,4 +27,6 @@ when ATTEMPT == 0:
|
||||||
# bug #1543
|
# bug #1543
|
||||||
import sequtils
|
import sequtils
|
||||||
|
|
||||||
(var i= @[""];i).mapIt(it)
|
(var i = @[""];i).mapIt(it)
|
||||||
|
# now works:
|
||||||
|
echo "##", i[0], "##"
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -23,7 +23,6 @@ version 1.0
|
||||||
- nimsuggest: auto-completion needs to work in 'class' macros
|
- nimsuggest: auto-completion needs to work in 'class' macros
|
||||||
- The bitwise 'not' operator will be renamed to 'bnot' to
|
- The bitwise 'not' operator will be renamed to 'bnot' to
|
||||||
prevent 'not 4 == 5' from compiling. -> requires 'mixin' annotation for procs!
|
prevent 'not 4 == 5' from compiling. -> requires 'mixin' annotation for procs!
|
||||||
- iterators always require a return type
|
|
||||||
- split docgen into separate tool
|
- split docgen into separate tool
|
||||||
- special rule for ``[]=``, items, pairs
|
- special rule for ``[]=``, items, pairs
|
||||||
- BUG: echo with template `$`*(info: TLineInfo): expr = toFileLineCol(info)
|
- BUG: echo with template `$`*(info: TLineInfo): expr = toFileLineCol(info)
|
||||||
|
|
|
||||||
192
web/news.txt
192
web/news.txt
|
|
@ -73,6 +73,8 @@ News
|
||||||
multi methods less error-prone to use with the effect system.
|
multi methods less error-prone to use with the effect system.
|
||||||
- Nim's parser directive ``#!`` is now ``#?`` in order to produce no conflicts
|
- Nim's parser directive ``#!`` is now ``#?`` in order to produce no conflicts
|
||||||
with Unix's ``#!``.
|
with Unix's ``#!``.
|
||||||
|
- An implicit return type for an iterator is now deprecated. Use ``auto`` if
|
||||||
|
you want more type inference.
|
||||||
|
|
||||||
|
|
||||||
Library Additions
|
Library Additions
|
||||||
|
|
@ -114,6 +116,196 @@ News
|
||||||
|
|
||||||
Bugfixes
|
Bugfixes
|
||||||
--------
|
--------
|
||||||
|
- Fixed "Compiler internal error on iterator it(T: typedesc[Base]) called with
|
||||||
|
it(Child), where Child = object of Base"
|
||||||
|
(`#2662 <https://github.com/Araq/Nim/issues/2662>`_)
|
||||||
|
- Fixed "repr() misses base object field in 2nd level derived object"
|
||||||
|
(`#2749 <https://github.com/Araq/Nim/issues/2749>`_)
|
||||||
|
- Fixed "nimsuggest doesn't work more than once on the non-main file"
|
||||||
|
(`#2694 <https://github.com/Araq/Nim/issues/2694>`_)
|
||||||
|
- Fixed "JS Codegen. Passing arguments by var in certain cases leads to invali
|
||||||
|
d JS."
|
||||||
|
(`#2798 <https://github.com/Araq/Nim/issues/2798>`_)
|
||||||
|
- Fixed ""check" proc in unittest.nim prevents the propagation of changes to v
|
||||||
|
ar parameters."
|
||||||
|
(`#964 <https://github.com/Araq/Nim/issues/964>`_)
|
||||||
|
- Fixed "Excessive letters in integer literals are not an error"
|
||||||
|
(`#2523 <https://github.com/Araq/Nim/issues/2523>`_)
|
||||||
|
- Fixed "Unicode dashes as "lisp'ish" alternative to hump and snake notation"
|
||||||
|
(`#2811 <https://github.com/Araq/Nim/issues/2811>`_)
|
||||||
|
- Fixed "Bad error message when trying to construct an object incorrectly"
|
||||||
|
(`#2584 <https://github.com/Araq/Nim/issues/2584>`_)
|
||||||
|
- Fixed "Determination of GC safety of globals is broken "
|
||||||
|
(`#2854 <https://github.com/Araq/Nim/issues/2854>`_)
|
||||||
|
- Fixed "v2 gc crashes compiler"
|
||||||
|
(`#2687 <https://github.com/Araq/Nim/issues/2687>`_)
|
||||||
|
- Fixed "Compile error using object in const array"
|
||||||
|
(`#2774 <https://github.com/Araq/Nim/issues/2774>`_)
|
||||||
|
- Fixed "httpclient async requests with method httpPOST isn't sending Content-
|
||||||
|
Length header"
|
||||||
|
(`#2884 <https://github.com/Araq/Nim/issues/2884>`_)
|
||||||
|
- Fixed "Streams module not working with JS backend"
|
||||||
|
(`#2148 <https://github.com/Araq/Nim/issues/2148>`_)
|
||||||
|
- Fixed "Sign of certain short constants is wrong"
|
||||||
|
(`#1179 <https://github.com/Araq/Nim/issues/1179>`_)
|
||||||
|
- Fixed "Symlinks to directories reported as symlinks to files"
|
||||||
|
(`#1985 <https://github.com/Araq/Nim/issues/1985>`_)
|
||||||
|
- Fixed "64-bit literals broken on x86"
|
||||||
|
(`#2909 <https://github.com/Araq/Nim/issues/2909>`_)
|
||||||
|
- Fixed "import broken for certain names"
|
||||||
|
(`#2904 <https://github.com/Araq/Nim/issues/2904>`_)
|
||||||
|
- Fixed "Invalid UTF-8 strings in JavaScript"
|
||||||
|
(`#2917 <https://github.com/Araq/Nim/issues/2917>`_)
|
||||||
|
- Fixed "[JS][Codegen] Initialising object doesn't create unmentioned fields."
|
||||||
|
|
||||||
|
(`#2617 <https://github.com/Araq/Nim/issues/2617>`_)
|
||||||
|
- Fixed "Table returned from proc computed at compile time is missing keys:"
|
||||||
|
(`#2297 <https://github.com/Araq/Nim/issues/2297>`_)
|
||||||
|
- Fixed "Clarify copyright status for some files"
|
||||||
|
(`#2949 <https://github.com/Araq/Nim/issues/2949>`_)
|
||||||
|
- Fixed "math.nim: trigonometry: radians to degrees conversion"
|
||||||
|
(`#2881 <https://github.com/Araq/Nim/issues/2881>`_)
|
||||||
|
- Fixed "xoring unsigned integers yields RangeError in certain conditions"
|
||||||
|
(`#2979 <https://github.com/Araq/Nim/issues/2979>`_)
|
||||||
|
- Fixed "Directly checking equality between procs"
|
||||||
|
(`#2985 <https://github.com/Araq/Nim/issues/2985>`_)
|
||||||
|
- Fixed "Compiler crashed, but there have to be meaningful error message"
|
||||||
|
(`#2974 <https://github.com/Araq/Nim/issues/2974>`_)
|
||||||
|
- Fixed "repr is broken"
|
||||||
|
(`#2992 <https://github.com/Araq/Nim/issues/2992>`_)
|
||||||
|
- Fixed "Ipv6 devel - add IPv6 support for asyncsockets, make AF_INET6 a defau
|
||||||
|
lt"
|
||||||
|
(`#2976 <https://github.com/Araq/Nim/issues/2976>`_)
|
||||||
|
- Fixed "Compilation broken on windows"
|
||||||
|
(`#2996 <https://github.com/Araq/Nim/issues/2996>`_)
|
||||||
|
- Fixed "'u64 literal conversion compiler error"
|
||||||
|
(`#2731 <https://github.com/Araq/Nim/issues/2731>`_)
|
||||||
|
- Fixed "Importing 'impure' libraries while using threads causes segfaults"
|
||||||
|
(`#2672 <https://github.com/Araq/Nim/issues/2672>`_)
|
||||||
|
- Fixed "Uncatched exception in async procedure on raise statement"
|
||||||
|
(`#3014 <https://github.com/Araq/Nim/issues/3014>`_)
|
||||||
|
- Fixed "nim doc2 fails in Mac OS X due to system.nim (possibly related to #18
|
||||||
|
98)"
|
||||||
|
(`#3005 <https://github.com/Araq/Nim/issues/3005>`_)
|
||||||
|
- Fixed "IndexError when rebuilding Nim on iteration 2"
|
||||||
|
(`#3018 <https://github.com/Araq/Nim/issues/3018>`_)
|
||||||
|
- Fixed "Assigning large const set to variable looses some information"
|
||||||
|
(`#2880 <https://github.com/Araq/Nim/issues/2880>`_)
|
||||||
|
- Fixed "Inconsistent generics behavior"
|
||||||
|
(`#3022 <https://github.com/Araq/Nim/issues/3022>`_)
|
||||||
|
- Fixed "Compiler breaks on float64 division"
|
||||||
|
(`#3028 <https://github.com/Araq/Nim/issues/3028>`_)
|
||||||
|
- Fixed "Confusing error message comparing string to nil "
|
||||||
|
(`#2935 <https://github.com/Araq/Nim/issues/2935>`_)
|
||||||
|
- Fixed "convert 64bit number to float on 32bit"
|
||||||
|
(`#1463 <https://github.com/Araq/Nim/issues/1463>`_)
|
||||||
|
- Fixed "Type redefinition and construction will break nim check"
|
||||||
|
(`#3032 <https://github.com/Araq/Nim/issues/3032>`_)
|
||||||
|
- Fixed "XmlParser fails on very large XML files without new lines"
|
||||||
|
(`#2429 <https://github.com/Araq/Nim/issues/2429>`_)
|
||||||
|
- Fixed "Error parsing arguments with whitespaces"
|
||||||
|
(`#2874 <https://github.com/Araq/Nim/issues/2874>`_)
|
||||||
|
- Fixed "Crash when missing one arg and used a named arg"
|
||||||
|
(`#2993 <https://github.com/Araq/Nim/issues/2993>`_)
|
||||||
|
- Fixed "Wrong number of arguments in assert will break nim check"
|
||||||
|
(`#3044 <https://github.com/Araq/Nim/issues/3044>`_)
|
||||||
|
- Fixed "Wrong const definition will break nim check"
|
||||||
|
(`#3041 <https://github.com/Araq/Nim/issues/3041>`_)
|
||||||
|
- Fixed "Wrong set declaration will break nim check"
|
||||||
|
(`#3040 <https://github.com/Araq/Nim/issues/3040>`_)
|
||||||
|
- Fixed "Compiler segfault (type section)"
|
||||||
|
(`#2540 <https://github.com/Araq/Nim/issues/2540>`_)
|
||||||
|
- Fixed "Segmentation fault when compiling this code"
|
||||||
|
(`#3038 <https://github.com/Araq/Nim/issues/3038>`_)
|
||||||
|
- Fixed "Kill nim i"
|
||||||
|
(`#2633 <https://github.com/Araq/Nim/issues/2633>`_)
|
||||||
|
- Fixed "Nim check will break on wrong array declaration"
|
||||||
|
(`#3048 <https://github.com/Araq/Nim/issues/3048>`_)
|
||||||
|
- Fixed "boolVal seems to be broken"
|
||||||
|
(`#3046 <https://github.com/Araq/Nim/issues/3046>`_)
|
||||||
|
- Fixed "Nim check crashes on wrong set/array declaration inside ref object"
|
||||||
|
(`#3062 <https://github.com/Araq/Nim/issues/3062>`_)
|
||||||
|
- Fixed "Nim check crashes on incorrect generic arg definition"
|
||||||
|
(`#3051 <https://github.com/Araq/Nim/issues/3051>`_)
|
||||||
|
- Fixed "Nim check crashes on iterating nonexistent var"
|
||||||
|
(`#3053 <https://github.com/Araq/Nim/issues/3053>`_)
|
||||||
|
- Fixed "Nim check crashes on wrong param set declaration + iteration"
|
||||||
|
(`#3054 <https://github.com/Araq/Nim/issues/3054>`_)
|
||||||
|
- Fixed "Wrong sharing of static_t instantations"
|
||||||
|
(`#3112 <https://github.com/Araq/Nim/issues/3112>`_)
|
||||||
|
- Fixed "Automatically generated proc conflicts with user-defined proc when .e
|
||||||
|
xportc.'ed"
|
||||||
|
(`#3134 <https://github.com/Araq/Nim/issues/3134>`_)
|
||||||
|
- Fixed "getTypeInfo call crashes nim"
|
||||||
|
(`#3099 <https://github.com/Araq/Nim/issues/3099>`_)
|
||||||
|
- Fixed "Array ptr dereference"
|
||||||
|
(`#2963 <https://github.com/Araq/Nim/issues/2963>`_)
|
||||||
|
- Fixed "Internal error when `repr`-ing a type directly"
|
||||||
|
(`#3079 <https://github.com/Araq/Nim/issues/3079>`_)
|
||||||
|
- Fixed "unknown type name 'TNimType' after importing typeinfo module"
|
||||||
|
(`#2841 <https://github.com/Araq/Nim/issues/2841>`_)
|
||||||
|
- Fixed "Can export a template twice and from inside a block"
|
||||||
|
(`#1738 <https://github.com/Araq/Nim/issues/1738>`_)
|
||||||
|
- Fixed "C Codegen: C Types are defined after their usage in certain cases"
|
||||||
|
(`#2823 <https://github.com/Araq/Nim/issues/2823>`_)
|
||||||
|
- Fixed "s.high refers to the current seq instead of the old one"
|
||||||
|
(`#1832 <https://github.com/Araq/Nim/issues/1832>`_)
|
||||||
|
- Fixed "Error while unmarshaling null values"
|
||||||
|
(`#3149 <https://github.com/Araq/Nim/issues/3149>`_)
|
||||||
|
- Fixed "Inference of `static[T]` in sequences"
|
||||||
|
(`#3144 <https://github.com/Araq/Nim/issues/3144>`_)
|
||||||
|
- Fixed "Argument named "closure" to proc inside template interfere with closu
|
||||||
|
re pragma"
|
||||||
|
(`#3171 <https://github.com/Araq/Nim/issues/3171>`_)
|
||||||
|
- Fixed "Internal error with aliasing inside template"
|
||||||
|
(`#3158 <https://github.com/Araq/Nim/issues/3158>`_)
|
||||||
|
- Fixed "Cardinality of sets prints unexpected value"
|
||||||
|
(`#3135 <https://github.com/Araq/Nim/issues/3135>`_)
|
||||||
|
- Fixed "Nim crashes on const assignment from function returning var ref objec
|
||||||
|
t"
|
||||||
|
(`#3103 <https://github.com/Araq/Nim/issues/3103>`_)
|
||||||
|
- Fixed "`repr` cstring"
|
||||||
|
(`#3080 <https://github.com/Araq/Nim/issues/3080>`_)
|
||||||
|
- Fixed "Nim check crashes on wrong enum declaration"
|
||||||
|
(`#3052 <https://github.com/Araq/Nim/issues/3052>`_)
|
||||||
|
- Fixed "Compiler assertion when evaluating template with static[T]"
|
||||||
|
(`#1858 <https://github.com/Araq/Nim/issues/1858>`_)
|
||||||
|
- Fixed "Erroneous overflow in iterators when compiler built with overflowChec
|
||||||
|
ks enabled"
|
||||||
|
(`#3140 <https://github.com/Araq/Nim/issues/3140>`_)
|
||||||
|
- Fixed "Unicode dashes as "lisp'ish" alternative to hump and snake notation"
|
||||||
|
(`#2811 <https://github.com/Araq/Nim/issues/2811>`_)
|
||||||
|
- Fixed "Calling discardable proc from a defer is an error."
|
||||||
|
(`#3185 <https://github.com/Araq/Nim/issues/3185>`_)
|
||||||
|
- Fixed "Defer statement at the end of a block produces ICE"
|
||||||
|
(`#3186 <https://github.com/Araq/Nim/issues/3186>`_)
|
||||||
|
- Fixed "Call to `createU` fails to compile"
|
||||||
|
(`#3193 <https://github.com/Araq/Nim/issues/3193>`_)
|
||||||
|
- Fixed "VM crash when accessing array's element"
|
||||||
|
(`#3192 <https://github.com/Araq/Nim/issues/3192>`_)
|
||||||
|
- Fixed "Unexpected proc invoked when different modules add procs to a type fr
|
||||||
|
om a 3rd module"
|
||||||
|
(`#2664 <https://github.com/Araq/Nim/issues/2664>`_)
|
||||||
|
- Fixed "Nim crashes on conditional declaration inside a template"
|
||||||
|
(`#2670 <https://github.com/Araq/Nim/issues/2670>`_)
|
||||||
|
- Fixed "Iterator names conflict within different scopes"
|
||||||
|
(`#2752 <https://github.com/Araq/Nim/issues/2752>`_)
|
||||||
|
- Fixed "VM: Cannot assign int value to ref variable"
|
||||||
|
(`#1329 <https://github.com/Araq/Nim/issues/1329>`_)
|
||||||
|
- Fixed "Incorrect code generated for tagged unions with enums not starting at
|
||||||
|
zero"
|
||||||
|
(`#3096 <https://github.com/Araq/Nim/issues/3096>`_)
|
||||||
|
- Fixed "Compile time procs using forward declarations are silently ignored"
|
||||||
|
(`#3066 <https://github.com/Araq/Nim/issues/3066>`_)
|
||||||
|
- Fixed "re binding error in generic"
|
||||||
|
(`#1965 <https://github.com/Araq/Nim/issues/1965>`_)
|
||||||
|
- Fixed "os.getCreationTime is incorrect/impossible on Posix systems"
|
||||||
|
(`#1058 <https://github.com/Araq/Nim/issues/1058>`_)
|
||||||
|
- Fixed "Improve error message for osproc.startProcess when command does not e
|
||||||
|
xist"
|
||||||
|
(`#2183 <https://github.com/Araq/Nim/issues/2183>`_)
|
||||||
|
- Fixed "gctest segfaults with --gc:markandsweep on x86_64"
|
||||||
|
(`#2305 <https://github.com/Araq/Nim/issues/2305>`_)
|
||||||
|
|
||||||
|
|
||||||
2015-05-04 Version 0.11.2 released
|
2015-05-04 Version 0.11.2 released
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue