Showing with 797 additions and 295 deletions.
  1. +2 −2 changelogs/changelog_0_18_1.md
  2. +68 −0 changelogs/changelog_1_0_6.md
  3. +3 −0 compiler/aliases.nim
  4. +1 −1 compiler/ast.nim
  5. +5 −4 compiler/cgen.nim
  6. +3 −3 compiler/commands.nim
  7. +30 −15 compiler/docgen.nim
  8. +1 −1 compiler/docgen2.nim
  9. +1 −0 compiler/installer.ini
  10. +3 −6 compiler/int128.nim
  11. +12 −1 compiler/jsgen.nim
  12. +1 −1 compiler/liftdestructors.nim
  13. +1 −0 compiler/msgs.nim
  14. +15 −3 compiler/nim.nim
  15. +3 −2 compiler/nimblecmd.nim
  16. +3 −2 compiler/nimconf.nim
  17. +1 −3 compiler/options.nim
  18. +26 −22 compiler/parser.nim
  19. +2 −2 compiler/semcall.nim
  20. +11 −10 compiler/semstmts.nim
  21. +9 −0 compiler/semtempl.nim
  22. +4 −2 compiler/vm.nim
  23. +1 −1 compiler/vmdef.nim
  24. +11 −3 compiler/vmgen.nim
  25. +1 −0 config/nimdoc.cfg
  26. +25 −23 doc/grammar.txt
  27. +1 −1 doc/intern.rst
  28. +26 −6 doc/manual.rst
  29. +3 −3 doc/manual/var_t_return.rst
  30. +3 −3 doc/manual_experimental.rst
  31. +8 −0 doc/tools.rst
  32. +2 −5 doc/tut1.rst
  33. +1 −1 lib/impure/re.nim
  34. +1 −1 lib/nimrtl.nim
  35. +5 −5 lib/pure/asyncftpclient.nim
  36. +11 −11 lib/pure/asyncnet.nim
  37. +28 −4 lib/pure/collections/tables.nim
  38. +6 −2 lib/pure/distros.nim
  39. +3 −3 lib/pure/httpclient.nim
  40. +0 −1 lib/pure/includes/osseps.nim
  41. +74 −74 lib/pure/net.nim
  42. +1 −1 lib/pure/osproc.nim
  43. +3 −2 lib/pure/parseutils.nim
  44. +3 −0 lib/pure/strformat.nim
  45. +4 −3 lib/pure/times.nim
  46. +29 −10 lib/system.nim
  47. +2 −2 lib/system/alloc.nim
  48. +4 −0 lib/system/ansi_c.nim
  49. +1 −1 lib/system/assertions.nim
  50. +6 −5 lib/system/atomics.nim
  51. +114 −0 lib/system/channels.nim
  52. +4 −1 lib/system/deepcopy.nim
  53. +33 −10 lib/system/excpt.nim
  54. +5 −3 lib/system/io.nim
  55. +1 −1 lib/system/repr.nim
  56. +1 −1 lib/system/sets.nim
  57. +1 −1 lib/wrappers/linenoise/linenoise.c
  58. +1 −0 nimdoc/test_out_index_dot_html/expected/index.html
  59. +1 −0 nimdoc/test_out_index_dot_html/expected/theindex.html
  60. +1 −0 nimdoc/testproject/expected/subdir/subdir_b/utils.html
  61. +1 −0 nimdoc/testproject/expected/testproject.html
  62. +1 −0 nimdoc/testproject/expected/theindex.html
  63. +2 −2 readme.md
  64. +2 −2 testament/backend.nim
  65. +3 −3 testament/categories.nim
  66. +1 −1 testament/htmlgen.nim
  67. +1 −1 testament/important_packages.nim
  68. +7 −7 testament/testament.nim
  69. +1 −1 tests/assert/tfailedassert.nim
  70. +9 −0 tests/assign/tassign.nim
  71. +5 −0 tests/compilerapi/myscript.nim
  72. +1 −0 tests/compilerapi/tcompilerapi.nim
  73. +2 −2 tests/deps/x11-1.0/xkb.nim
  74. +1 −1 tests/deps/x11-1.0/xkblib.nim
  75. +17 −0 tests/destructor/tnewruntime_misc.nim
  76. +9 −1 tests/js/tcopying.nim
  77. +22 −0 tests/objects/t12753.nim
  78. +3 −0 tests/tools/second.nim
  79. +11 −2 tests/tools/tunused_imports.nim
  80. +17 −0 tests/vm/tmisc_vm.nim
  81. +47 −0 tools/grammar_nanny.nim
  82. +4 −4 tools/nimfind.nim
4 changes: 2 additions & 2 deletions changelogs/changelog_0_18_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

- We changed how array accesses "from backwards" like ``a[^1]`` or ``a[0..^1]`` are
implemented. These are now implemented purely in ``system.nim`` without compiler
support. There is a new "heterogenous" slice type ``system.HSlice`` that takes 2
support. There is a new "heterogeneous" slice type ``system.HSlice`` that takes 2
generic parameters which can be ``BackwardsIndex`` indices. ``BackwardsIndex`` is
produced by ``system.^``.
This means if you overload ``[]`` or ``[]=`` you need to ensure they also work
Expand Down Expand Up @@ -660,4 +660,4 @@ for i in a..b:
- Fixed "C++: SIGABRT instead of IndexError for out-of-bounds"
([#6512](https://github.com/nim-lang/Nim/issues/6512))
- Fixed "An uncaught exception in cpp mode doesn't show the exception name/msg"
([#6431](https://github.com/nim-lang/Nim/issues/6431))
([#6431](https://github.com/nim-lang/Nim/issues/6431))
68 changes: 68 additions & 0 deletions changelogs/changelog_1_0_6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# v1.0.6 - 2020-01-24


## Bugfixes

### Fixed issues

- Fixed "Nim stdlib style issues with --styleCheck:error"
([#12687](https://github.com/nim-lang/Nim/issues/12687))
- Fixed "new(ref MyObject) doesn't work at compile time"
([#12488](https://github.com/nim-lang/Nim/issues/12488))
- Fixed "Accessing the wrong variant field in the VM does not trigger the appropriate error message"
([#11727](https://github.com/nim-lang/Nim/issues/11727))
- Fixed "orderedTable.del() crashes with unitialized table"
([#12798](https://github.com/nim-lang/Nim/issues/12798))
- Fixed "semfold bug with negative value * 0"
([#12783](https://github.com/nim-lang/Nim/issues/12783))
- Fixed "nimsuggest `use` command does not return all instances of symbol"
([#12832](https://github.com/nim-lang/Nim/issues/12832))
- Fixed "Codegen ICE in allPathsAsgnResult"
([#12827](https://github.com/nim-lang/Nim/issues/12827))
- Fixed "Static[T] + syntactic error in the for loop = compiler crash"
([#12148](https://github.com/nim-lang/Nim/issues/12148))
- Fixed "Incorrect unused import warning involving templates and tables"
([#12885](https://github.com/nim-lang/Nim/issues/12885))
- Fixed "regression(1.0.4): undeclared identifier: 'readLines'; plus another regression and bug"
([#13013](https://github.com/nim-lang/Nim/issues/13013))
- Fixed "`nim doc` treats `export localSymbol` incorrectly"
([#13100](https://github.com/nim-lang/Nim/issues/13100))
- Fixed "symbols not defined in the grammar"
([#10665](https://github.com/nim-lang/Nim/issues/10665))
- Fixed "nim-gdb is missing from all released packages"
([#13104](https://github.com/nim-lang/Nim/issues/13104))
- Fixed "[JS] Move is not defined"
([#9674](https://github.com/nim-lang/Nim/issues/9674))
- Fixed "Error: usage of 'isNil' is a user-defined error"
([#11440](https://github.com/nim-lang/Nim/issues/11440))


### Other bugfixes

- make addQuoted work on nimscript (#12717)
- fix db_mysql getRow() when column is null error raised (#12806)
- Fixed objects being erroneously zeroed out before object construction (#12814)
- added cstrutils (#12858): fixed for 'csuCmpIgnoreStyle' error on hotcodereloading
- Better clang_cl support (#12896)
- fix cmdline bugs affecting nimBetterRun correctness (#12933)
- fixes a bug that kept sugar.collect from working with for loop macros
- Path substitution for --out and --outdir (#12796)
- fix crash due to errant symbols in nim.cfg (#13073)
- Allow `-o` option for `buildIndex` (#13037)
- Deleted misplaced separator (#13085): Misplaced separator, which was constantly breaking compilation on Haiku OS, was deleted.
- fixes an asyncftpclient bug; refs #13096
- fix the ftp store function read the local file bug (#13108)
- fix rtti sizeof for varargs in global scope (#13125)
- Correctly remove a key from CountTable when it is set to zero.
- fixes the distros.nim regression
- fixes a critical times.nim bug reported on IRC
- c_fflush() the rawWrite() buffer


## Documentation improvements

- Fixed "Documentation, Testament missing from "Tools available with Nim""
([#12251](https://github.com/nim-lang/Nim/issues/12251))
- Manual update: custom exceptions (#12847)
- times/getClockStr(): fix mistake in doc
- Fix typo and improve in code-block of 'lib/pure/parseutils.nim'
3 changes: 3 additions & 0 deletions compiler/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult =
if res != arNo:
result = res
if res == arYes: break
of nkBracket:
if b.len > 0:
result = isPartOf(a, b[0])
else: discard
2 changes: 1 addition & 1 deletion compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ type
tfContravariant # contravariant generic param
tfCheckedForDestructor # type was checked for having a destructor.
# If it has one, t.destructor is not nil.
tfIncompleteStruct # treat this type as if it had sizeof(pointer)

TTypeFlags* = set[TTypeFlag]

Expand Down Expand Up @@ -577,7 +578,6 @@ type
const
routineKinds* = {skProc, skFunc, skMethod, skIterator,
skConverter, skMacro, skTemplate}
tfIncompleteStruct* = tfVarargs
tfUnion* = tfNoSideEffect
tfGcSafe* = tfThread
tfObjHasKids* = tfEnumHasHoles
Expand Down
9 changes: 5 additions & 4 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,12 @@ proc allPathsAsgnResult(n: PNode): InitResultEnum =
# assignment this is not good enough! The only pattern we allow for
# is 'finally: result = x'
result = InitSkippable
for it in n:
if it.kind == nkFinally:
result = allPathsAsgnResult(it.lastSon)
allPathsInBranch(n[0])
for i in 1..<n.len:
if n[i].kind == nkFinally:
result = allPathsAsgnResult(n[i].lastSon)
else:
allPathsInBranch(it.lastSon)
allPathsInBranch(n[i].lastSon)
else:
for i in 0..<safeLen(n):
allPathsInBranch(n[i])
Expand Down
6 changes: 3 additions & 3 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
conf.lazyPaths.keepItIf(it != path)
of "nimcache":
expectArg(conf, switch, arg, pass, info)
conf.nimcacheDir = processPath(conf, arg, info, true)
conf.nimcacheDir = processPath(conf, arg, info, notRelativeToProj=true)
of "out", "o":
expectArg(conf, switch, arg, pass, info)
let f = splitFile(arg.expandTilde)
let f = splitFile(processPath(conf, arg, info, notRelativeToProj=true).string)
conf.outFile = RelativeFile f.name & f.ext
conf.outDir = toAbsoluteDir f.dir
of "outdir":
expectArg(conf, switch, arg, pass, info)
conf.outDir = toAbsoluteDir arg.expandTilde
conf.outDir = processPath(conf, arg, info, notRelativeToProj=true)
of "docseesrcurl":
expectArg(conf, switch, arg, pass, info)
conf.docSeeSrcUrl = arg
Expand Down
45 changes: 30 additions & 15 deletions compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type
TSections = array[TSymKind, Rope]
TDocumentor = object of rstgen.RstGenerator
modDesc: Rope # module description
module: PSym
modDeprecationMsg: Rope
toc, section: TSections
indexValFilename: string
Expand Down Expand Up @@ -115,9 +116,10 @@ proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
else:
result = getOutFile(conf, filename, ext)

proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef, outExt: string = HtmlExt): PDoc =
proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef, outExt: string = HtmlExt, module: PSym = nil): PDoc =
declareClosures()
new(result)
result.module = module
result.conf = conf
result.cache = cache
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
Expand Down Expand Up @@ -631,8 +633,12 @@ proc genDeprecationMsg(d: PDoc, n: PNode): Rope =
else:
doAssert false

proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
if not isVisible(d, nameNode): return
type DocFlags = enum
kDefault
kForceExport

proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind, docFlags: DocFlags) =
if (docFlags != kForceExport) and not isVisible(d, nameNode): return
let
name = getName(d, nameNode)
nameRope = name.rope
Expand Down Expand Up @@ -848,35 +854,37 @@ proc documentRaises*(cache: IdentCache; n: PNode) =
if p4 != nil: n.sons[pragmasPos].add p4
if p5 != nil: n.sons[pragmasPos].add p5

proc generateDoc*(d: PDoc, n, orig: PNode) =
proc generateDoc*(d: PDoc, n, orig: PNode, docFlags: DocFlags = kDefault) =
template genItemAux(skind) =
genItem(d, n, n[namePos], skind, docFlags)
case n.kind
of nkPragma:
let pragmaNode = findPragma(n, wDeprecated)
add(d.modDeprecationMsg, genDeprecationMsg(d, pragmaNode))
of nkCommentStmt: add(d.modDesc, genComment(d, n))
of nkProcDef:
when useEffectSystem: documentRaises(d.cache, n)
genItem(d, n, n.sons[namePos], skProc)
genItemAux(skProc)
of nkFuncDef:
when useEffectSystem: documentRaises(d.cache, n)
genItem(d, n, n.sons[namePos], skFunc)
genItemAux(skFunc)
of nkMethodDef:
when useEffectSystem: documentRaises(d.cache, n)
genItem(d, n, n.sons[namePos], skMethod)
genItemAux(skMethod)
of nkIteratorDef:
when useEffectSystem: documentRaises(d.cache, n)
genItem(d, n, n.sons[namePos], skIterator)
of nkMacroDef: genItem(d, n, n.sons[namePos], skMacro)
of nkTemplateDef: genItem(d, n, n.sons[namePos], skTemplate)
genItemAux(skIterator)
of nkMacroDef: genItemAux(skMacro)
of nkTemplateDef: genItemAux(skTemplate)
of nkConverterDef:
when useEffectSystem: documentRaises(d.cache, n)
genItem(d, n, n.sons[namePos], skConverter)
genItemAux(skConverter)
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
for i in 0 ..< len(n):
if n.sons[i].kind != nkCommentStmt:
# order is always 'type var let const':
genItem(d, n.sons[i], n.sons[i].sons[0],
succ(skType, ord(n.kind)-ord(nkTypeSection)))
genItem(d, n[i], n[i][0],
succ(skType, ord(n.kind)-ord(nkTypeSection)), docFlags)
of nkStmtList:
for i in 0 ..< len(n): generateDoc(d, n.sons[i], orig)
of nkWhenStmt:
Expand All @@ -887,7 +895,11 @@ proc generateDoc*(d: PDoc, n, orig: PNode) =
for it in n: traceDeps(d, it)
of nkExportStmt:
for it in n:
if it.kind == nkSym: exportSym(d, it.sym)
if it.kind == nkSym:
if d.module != nil and d.module == it.sym.owner:
generateDoc(d, it.sym.ast, orig, kForceExport)
else:
exportSym(d, it.sym)
of nkExportExceptStmt: discard "transformed into nkExportStmt by semExportExcept"
of nkFromStmt, nkImportExceptStmt: traceDeps(d, n.sons[0])
of nkCallKinds:
Expand Down Expand Up @@ -1169,6 +1181,9 @@ proc commandBuildIndex*(cache: IdentCache, conf: ConfigRef) =
["Index".rope, nil, nil, rope(getDateStr()),
rope(getClockStr()), content, nil, nil, nil])
# no analytics because context is not available
let filename = getOutFile(conf, RelativeFile"theindex", HtmlExt)
var outFile = RelativeFile"theindex"
if conf.outFile != RelativeFile"":
outFile = conf.outFile
let filename = getOutFile(conf, outFile, HtmlExt)
if not writeRope(code, filename):
rawMessage(conf, errCannotOpenFile, filename.string)
2 changes: 1 addition & 1 deletion compiler/docgen2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ template myOpenImpl(ext: untyped) {.dirty.} =
g.module = module
g.config = graph.config
var d = newDocumentor(AbsoluteFile toFullPath(graph.config, FileIndex module.position),
graph.cache, graph.config, ext)
graph.cache, graph.config, ext, module)
d.hasToc = true
g.doc = d
result = g
Expand Down
1 change: 1 addition & 0 deletions compiler/installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Files: "compiler"
Files: "doc"
Files: "doc/html"
Files: "tools"
Files: "tools/nim-gdb.py"
Files: "nimpretty"
Files: "testament"
Files: "nimsuggest"
Expand Down
9 changes: 3 additions & 6 deletions compiler/int128.nim
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ proc `*`(a: Int128, b: uint32): Int128 =
result.udata[3] = cast[uint32](tmp3) + cast[uint32](tmp2 shr 32)

proc `*`*(a: Int128, b: int32): Int128 =
let isNegative = isNegative(a) xor isNegative(b)
result = a * cast[uint32](abs(b))
if b < 0:
result = -result
Expand All @@ -356,8 +355,6 @@ proc low64(a: Int128): uint64 =
bitconcat(a.udata[1], a.udata[0])

proc `*`*(lhs,rhs: Int128): Int128 =
let isNegative = isNegative(lhs) xor isNegative(rhs)

let
a = cast[uint64](lhs.udata[0])
b = cast[uint64](lhs.udata[1])
Expand All @@ -379,9 +376,6 @@ proc `*`*(lhs,rhs: Int128): Int128 =
result = result + toInt128(a32 * b00) shl 32
result = result + toInt128(a00 * b32) shl 32

if isNegative != isNegative(result):
assert(false, "overflow")

proc `*=`*(a: var Int128, b: Int128) =
a = a * b

Expand Down Expand Up @@ -684,6 +678,9 @@ when isMainModule:
var ma = 100'i64
var mb = 13

doAssert toInt128(ma) * toInt128(0) == toInt128(0)
doAssert toInt128(-ma) * toInt128(0) == toInt128(0)

# sign correctness
doAssert divMod(toInt128( ma),toInt128( mb)) == (toInt128( ma div mb), toInt128( ma mod mb))
doAssert divMod(toInt128(-ma),toInt128( mb)) == (toInt128(-ma div mb), toInt128(-ma mod mb))
Expand Down
13 changes: 12 additions & 1 deletion compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,15 @@ proc genReset(p: PProc, n: PNode) =
lineF(p, "$1 = genericReset($3, $2);$n", [a,
genTypeInfo(p, n.sons[1].typ), tmp])

proc genMove(p: PProc; n: PNode; r: var TCompRes) =
var a: TCompRes
r.kind = resVal
r.res = p.getTemp()
gen(p, n[1], a)
lineF(p, "$1 = $2;$n", [r.rdLoc, a.rdLoc])
genReset(p, n)
#lineF(p, "$1 = $2;$n", [dest.rdLoc, src.rdLoc])

proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
var
a: TCompRes
Expand Down Expand Up @@ -2018,7 +2027,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
of mNewSeqOfCap: unaryExpr(p, n, r, "", "[]")
of mOf: genOf(p, n, r)
of mDefault: genDefault(p, n, r)
of mReset: genReset(p, n)
of mReset, mWasMoved: genReset(p, n)
of mEcho: genEcho(p, n, r)
of mNLen..mNError, mSlurp, mStaticExec:
localError(p.config, n.info, errXMustBeCompileTime % n.sons[0].sym.name.s)
Expand All @@ -2041,6 +2050,8 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
gen(p, n.sons[3], z)
r.res = "($1.slice($2, $3+1))" % [x.rdLoc, y.rdLoc, z.rdLoc]
r.kind = resExpr
of mMove:
genMove(p, n, r)
else:
genCall(p, n, r)
#else internalError(p.config, e.info, 'genMagic: ' + magicToStr[op]);
Expand Down
2 changes: 1 addition & 1 deletion compiler/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ proc ownedRefOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =

proc closureOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
if c.kind == attachedDeepCopy:
# a big problem is that we don't know the enviroment's type here, so we
# a big problem is that we don't know the environment's type here, so we
# have to go through some indirection; we delegate this to the codegen:
let call = newNodeI(nkCall, c.info, 2)
call.typ = t
Expand Down
1 change: 1 addition & 0 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ proc fileInfoIdx*(conf: ConfigRef; filename: AbsoluteFile; isKnownFile: var bool
pseudoPath = true

if conf.m.filenameToIndexTbl.hasKey(canon.string):
isKnownFile = true
result = conf.m.filenameToIndexTbl[canon.string]
else:
isKnownFile = false
Expand Down
18 changes: 15 additions & 3 deletions compiler/nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,31 @@ proc prependCurDir(f: AbsoluteFile): AbsoluteFile =
else:
result = f

proc addCmdPrefix*(result: var string, kind: CmdLineKind) =
# consider moving this to std/parseopt
case kind
of cmdLongOption: result.add "--"
of cmdShortOption: result.add "-"
of cmdArgument, cmdEnd: discard

proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
var p = parseopt.initOptParser(cmd)
var argsCount = 0

config.commandLine.setLen 0
# bugfix: otherwise, config.commandLine ends up duplicated

while true:
parseopt.next(p)
case p.kind
of cmdEnd: break
of cmdLongOption, cmdShortOption:
config.commandLine.add " "
config.commandLine.add p.key
config.commandLine.addCmdPrefix p.kind
config.commandLine.add p.key.quoteShell # quoteShell to be future proof
if p.val.len > 0:
config.commandLine.add ':'
config.commandLine.add p.val
config.commandLine.add p.val.quoteShell

if p.key == " ":
p.key = "-"
Expand All @@ -61,7 +73,7 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
processSwitch(pass, p, config)
of cmdArgument:
config.commandLine.add " "
config.commandLine.add p.key
config.commandLine.add p.key.quoteShell
if processArgument(pass, p, argsCount, config): break
if pass == passCmd2:
if {optRun, optWasNimscript} * config.globalOptions == {} and
Expand Down
Loading