Showing with 885 additions and 340 deletions.
  1. +6 −0 .gitattributes
  2. +9 −0 azure-pipelines.yml
  3. +8 −1 changelog.md
  4. +1 −1 compiler/ccgexprs.nim
  5. +1 −4 compiler/cmdlinehelper.nim
  6. +10 −2 compiler/commands.nim
  7. +1 −1 compiler/extccomp.nim
  8. +3 −0 compiler/installer.ini
  9. +1 −1 compiler/jsgen.nim
  10. +3 −1 compiler/main.nim
  11. +1 −1 compiler/msgs.nim
  12. +6 −2 compiler/semcall.nim
  13. +9 −2 compiler/semexprs.nim
  14. +6 −3 compiler/semfold.nim
  15. +2 −2 compiler/semstmts.nim
  16. +3 −3 compiler/semtypes.nim
  17. +2 −1 compiler/sigmatch.nim
  18. +13 −4 compiler/transf.nim
  19. +5 −1 compiler/types.nim
  20. +1 −0 config/nim.cfg
  21. +3 −0 doc/lib.rst
  22. +28 −28 doc/manual.rst
  23. +11 −5 doc/tut1.rst
  24. +3 −3 koch.nim
  25. +5 −5 lib/impure/db_odbc.nim
  26. +3 −0 lib/impure/nre.nim
  27. +3 −1 lib/impure/re.nim
  28. +1 −1 lib/js/jsffi.nim
  29. +6 −1 lib/posix/posix_other.nim
  30. +3 −1 lib/pure/algorithm.nim
  31. +10 −4 lib/pure/asyncdispatch.nim
  32. +11 −6 lib/pure/asyncftpclient.nim
  33. +1 −1 lib/pure/asyncmacro.nim
  34. +17 −5 lib/pure/browsers.nim
  35. +13 −31 lib/pure/cgi.nim
  36. +11 −11 lib/pure/collections/intsets.nim
  37. +5 −0 lib/pure/collections/sharedtables.nim
  38. +16 −6 lib/pure/collections/tableimpl.nim
  39. +0 −13 lib/pure/collections/tables.nim
  40. +7 −1 lib/pure/httpclient.nim
  41. +24 −0 lib/pure/includes/decode_helpers.nim
  42. +8 −3 lib/pure/net.nim
  43. +2 −1 lib/pure/os.nim
  44. +5 −1 lib/pure/osproc.nim
  45. +2 −2 lib/pure/parsecsv.nim
  46. +25 −32 lib/pure/parseutils.nim
  47. +2 −1 lib/pure/pathnorm.nim
  48. +24 −24 lib/pure/pegs.nim
  49. +37 −2 lib/pure/smtp.nim
  50. +11 −14 lib/pure/unicode.nim
  51. +6 −12 lib/pure/uri.nim
  52. +6 −10 lib/std/monotimes.nim
  53. +1 −1 lib/system.nim
  54. +2 −8 lib/system/atomics.nim
  55. +3 −0 lib/system/io.nim
  56. +15 −0 lib/system/nimscript.nim
  57. +2 −0 lib/windows/winlean.nim
  58. +14 −12 lib/wrappers/odbcsql.nim
  59. +39 −19 lib/wrappers/openssl.nim
  60. +8 −0 nimsuggest/tests/tchk_compiles.nim
  61. +13 −0 nimsuggest/tests/ttempl_inst.nim
  62. +11 −13 testament/important_packages.nim
  63. +27 −0 tests/async/t13889.nim
  64. +1 −1 tests/async/t7758.nim
  65. +7 −2 tests/collections/ttables.nim
  66. +1 −1 tests/destructor/tgcdestructors.nim
  67. +1 −1 tests/destructor/twidgets_unown.nim
  68. +47 −0 tests/errmsgs/tsigmatch2.nim
  69. +11 −0 tests/iter/titer11.nim
  70. +13 −0 tests/misc/tdangerisrelease.nim
  71. +17 −0 tests/misc/tunsignedconv.nim
  72. +11 −0 tests/objects/tobject3.nim
  73. +64 −8 tests/sets/tsets_various.nim
  74. +65 −0 tests/stdlib/tintsets.nim
  75. +4 −0 tests/stdlib/tos.nim
  76. +80 −6 tests/stdlib/tsharedtable.nim
  77. +8 −1 tests/tuples/ttuples_issues.nim
  78. +9 −0 tests/types/tyet_another_generic_regression.nim
  79. +1 −1 tests/vm/tslow_tables.nim
  80. +2 −3 tools/finish.nim
  81. +8 −8 tools/kochdocs.nim
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Avoids changelog conflicts by assuming additions-only, which is by far the common case.
# In the rare case where branch b1 rebases against branch b2 and both branches
# modified the same changelog entry, you'll end up with that changelog entry
# duplicated, which is easily identifiable and fixable.
/changelog.md merge=union

9 changes: 9 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
trigger:
branches:
include:
- '*'
pr:
branches:
include:
- '*'

strategy:
matrix:
Linux_amd64:
Expand Down
9 changes: 8 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.1 - xxxx-xx-xx
# v1.0.8 - xxxx-xx-xx


## Changes affecting backwards compatibility
Expand All @@ -7,6 +7,9 @@

### Breaking changes in the standard library

- `CountTable.mget` has been removed from `tables.nim`. It didn't work, and it
was an oversight to be included in v1.0.



### Breaking changes in the compiler
Expand All @@ -15,6 +18,7 @@

## Library additions

- Added `browsers.osOpen` const alias for the operating system specific *"open"* command.


## Library changes
Expand All @@ -25,6 +29,9 @@



- Fix a bug where calling `close` on io streams in osproc.startProcess was a noop and led to
hangs if a process had both reads from stdin and writes (eg to stdout).

## Language changes


Expand Down
2 changes: 1 addition & 1 deletion compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
of mCard:
if size <= 4: unaryExprChar(p, e, d, "#countBits32($1)")
else: unaryExprChar(p, e, d, "#countBits64($1)")
of mLtSet: binaryExprChar(p, e, d, "(($1 & ~ $2 ==0)&&($1 != $2))")
of mLtSet: binaryExprChar(p, e, d, "((($1 & ~ $2)==0)&&($1 != $2))")
of mLeSet: binaryExprChar(p, e, d, "(($1 & ~ $2)==0)")
of mEqSet: binaryExpr(p, e, d, "($1 == $2)")
of mMulSet: binaryExpr(p, e, d, "($1 & $2)")
Expand Down
5 changes: 1 addition & 4 deletions compiler/cmdlinehelper.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) =
proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
self.processCmdLine(passCmd1, "", conf)
if self.supportsStdinFile and conf.projectName == "-":
conf.projectName = "stdinfile"
conf.projectFull = AbsoluteFile "stdinfile"
conf.projectPath = AbsoluteDir getCurrentDir()
conf.projectIsStdin = true
handleStdinInput(conf)
elif conf.projectName != "":
try:
conf.projectFull = canonicalizePath(conf, AbsoluteFile conf.projectName)
Expand Down
12 changes: 10 additions & 2 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ proc dynlibOverride(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, in
expectArg(conf, switch, arg, pass, info)
options.inclDynlibOverride(conf, arg)

proc handleStdinInput*(conf: ConfigRef) =
conf.projectName = "stdinfile"
conf.projectFull = conf.projectName.AbsoluteFile
conf.projectPath = AbsoluteDir getCurrentDir()
conf.projectIsStdin = true
if conf.outDir.isEmpty:
conf.outDir = getNimcacheDir(conf)

proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
conf: ConfigRef) =
var
Expand Down Expand Up @@ -795,8 +803,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
discard "the default"
else:
localError(conf, info, "unknown Nim version; currently supported values are: {1.0}")
of "":
conf.projectName = "-"
of "": # comes from "-" in for example: `nim c -r -` (gets stripped from -)
handleStdinInput(conf)
else:
if strutils.find(switch, '.') >= 0: options.setConfigVar(conf, switch, arg)
else: invalidCmdLineOption(conf, pass, switch, info)
Expand Down
2 changes: 1 addition & 1 deletion compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ compiler vcc:
buildDll: " /LD",
buildLib: "lib /OUT:$libfile $objfiles",
linkerExe: "cl",
linkTmpl: "$options $builddll$vccplatform /Fe$exefile $objfiles $buildgui",
linkTmpl: "$builddll$vccplatform /Fe$exefile $objfiles $buildgui $options",
includeCmd: " /I",
linkDirCmd: " /LIBPATH:",
linkLibCmd: " $1.lib",
Expand Down
3 changes: 3 additions & 0 deletions compiler/installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Files: "bin/vccexe.exe"
Files: "bin/nimgrab.exe"
Files: "bin/nimpretty.exe"
Files: "bin/testament.exe"
Files: "bin/nim-gdb.bat"

Files: "koch.exe"
Files: "finish.exe"
Expand Down Expand Up @@ -117,6 +118,8 @@ Files: "bin/nim"
[Unix]
InstallScript: "yes"
UninstallScript: "yes"
Files: "bin/nim-gdb"
Files: "bin/nim-gdb.bash"


[InnoSetup]
Expand Down
2 changes: 1 addition & 1 deletion compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
of tyObject:
var initList: Rope
createObjInitList(p, t, initIntSet(), initList)
result = ("{$1}") % [initList]
result = ("({$1})") % [initList]
if indirect: result = "[$1]" % [result]
of tyVar, tyPtr, tyLent, tyRef, tyPointer:
if mapType(p, t) == etyBaseIndex:
Expand Down
4 changes: 3 additions & 1 deletion compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ when not defined(nimcore):
{.error: "nimcore MUST be defined for Nim's core tooling".}

import
llstream, strutils, ast, lexer, syntaxes, options, msgs,
llstream, strutils, os, ast, lexer, syntaxes, options, msgs,
condsyms, times,
sem, idents, passes, extccomp,
cgen, json, nversion,
Expand Down Expand Up @@ -303,6 +303,8 @@ proc mainCommand*(graph: ModuleGraph) =

var dumpdata = %[
(key: "version", val: %VersionAsString),
(key: "nimExe", val: %(getAppFilename())),
(key: "prefixdir", val: %conf.getPrefixDir().string),
(key: "project_path", val: %conf.projectFull.string),
(key: "defined_symbols", val: definedSymbols),
(key: "lib_paths", val: %libpaths),
Expand Down
2 changes: 1 addition & 1 deletion compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ proc writeContext(conf: ConfigRef; lastinfo: TLineInfo) =
if context.info != lastinfo and context.info != info:
if conf.structuredErrorHook != nil:
conf.structuredErrorHook(conf, context.info, instantiationFrom,
Severity.Error)
Severity.Hint)
else:
let message = if context.detail == "":
instantiationFrom
Expand Down
8 changes: 6 additions & 2 deletions compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
candidates.add(" first type mismatch at position: " & $err.firstMismatch.arg)
# candidates.add "\n reason: " & $err.firstMismatch.kind # for debugging
case err.firstMismatch.kind
of kUnknownNamedParam: candidates.add("\n unknown named parameter: " & $nArg[0])
of kUnknownNamedParam:
if nArg == nil:
candidates.add("\n unknown named parameter")
else:
candidates.add("\n unknown named parameter: " & $nArg[0])
of kAlreadyGiven: candidates.add("\n named param already provided: " & $nArg[0])
of kPositionalAlreadyGiven: candidates.add("\n positional param was already given as named param")
of kExtraArg: candidates.add("\n extra argument given")
Expand Down Expand Up @@ -296,7 +300,7 @@ proc getMsgDiagnostic(c: PContext, flags: TExprFlags, n, f: PNode): string =
sym = nextOverloadIter(o, c, f)

let ident = considerQuotedIdent(c, f, n).s
if nfDotField in n.flags and nfExplicitCall notin n.flags:
if {nfDotField, nfExplicitCall} * n.flags == {nfDotField}:
let sym = n.sons[1].typ.sym
var typeHint = ""
if sym == nil:
Expand Down
11 changes: 9 additions & 2 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
addSon(a, m)
changeType(m, tup.sons[i], check)
of nkCharLit..nkUInt64Lit:
if check and n.kind != nkUInt64Lit:
if check and n.kind != nkUInt64Lit and not sameType(n.typ, newType):
let value = n.intVal
if value < firstOrd(c.config, newType) or value > lastOrd(c.config, newType):
localError(c.config, n.info, "cannot convert " & $value &
Expand Down Expand Up @@ -2034,6 +2034,10 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =

proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
# watch out, hacks ahead:
when defined(nimsuggest):
# Remove the error hook so nimsuggest doesn't report errors there
let tempHook = c.graph.config.structuredErrorHook
c.graph.config.structuredErrorHook = nil
let oldErrorCount = c.config.errorCounter
let oldErrorMax = c.config.errorMax
let oldCompilesId = c.compilesContextId
Expand Down Expand Up @@ -2080,6 +2084,9 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
c.config.m.errorOutputs = oldErrorOutputs
c.config.errorCounter = oldErrorCount
c.config.errorMax = oldErrorMax
when defined(nimsuggest):
# Restore the error hook
c.graph.config.structuredErrorHook = tempHook

proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode =
# we replace this node by a 'true' or 'false' node:
Expand Down Expand Up @@ -2394,7 +2401,7 @@ proc checkPar(c: PContext; n: PNode): TParKind =
for i in 0 ..< length:
if result == paTupleFields:
if (n.sons[i].kind != nkExprColonExpr) or
n.sons[i].sons[0].kind notin {nkSym, nkIdent}:
n.sons[i].sons[0].kind notin {nkSym, nkIdent, nkAccQuoted}:
localError(c.config, n.sons[i].info, errNamedExprExpected)
return paNone
else:
Expand Down
9 changes: 6 additions & 3 deletions compiler/semfold.nim
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode =
result = newIntNodeT(BiggestInt(getFloat(a)), n, g)
of tyChar, tyUInt..tyUInt64, tyInt..tyInt64:
var val = a.getOrdValue

if check: rangeCheck(n, val, g)
result = newIntNodeT(val, n, g)
if dstTyp.kind in {tyUInt..tyUInt64}:
Expand Down Expand Up @@ -734,7 +733,11 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
of nkBracketExpr: result = foldArrayAccess(m, n, g)
of nkDotExpr: result = foldFieldAccess(m, n, g)
of nkStmtListExpr:
if n.len == 2 and n[0].kind == nkComesFrom:
result = getConstExpr(m, n[1], g)
var i = 0
while i <= n.len - 2:
if n[i].kind in {nkComesFrom, nkCommentStmt, nkEmpty}: i.inc
else: break
if i == n.len - 1:
result = getConstExpr(m, n[i], g)
else:
discard
4 changes: 2 additions & 2 deletions compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,9 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
checkSonsLen(x, 1, c.config)
x.sons[0] = semExprBranchScope(c, x.sons[0])
typ = commonType(typ, x.sons[0])
hasElse = true
if chckCovered and covered == toCover(c, n.sons[0].typ):
if (chckCovered and covered == toCover(c, n[0].typ)) or hasElse:
localError(c.config, x.info, "invalid else, all cases are already covered")
hasElse = true
chckCovered = false
else:
illFormedAst(x, c.config)
Expand Down
6 changes: 3 additions & 3 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,15 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int,
case typ.kind
of shouldChckCovered:
chckCovered = true
of tyFloat..tyFloat128, tyString, tyError:
of tyFloat..tyFloat128, tyError:
discard
of tyRange:
if skipTypes(typ.sons[0], abstractInst).kind in shouldChckCovered:
chckCovered = true
of tyForward:
errorUndeclaredIdentifier(c, n.sons[0].info, typ.sym.name.s)
elif not isOrdinalType(typ):
localError(c.config, n.sons[0].info, "selector must be of an ordinal type, float or string")
localError(c.config, n.sons[0].info, "selector must be of an ordinal type or float")
if firstOrd(c.config, typ) != 0:
localError(c.config, n.info, "low(" & $a.sons[0].sym.name.s &
") must be 0 for discriminant")
Expand Down Expand Up @@ -768,7 +768,7 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
addInheritedFieldsAux(c, check, pos, lastSon(n.sons[i]))
else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)")
of nkRecList, nkRecWhen, nkElifBranch, nkElse:
for i in 0 ..< len(n):
for i in int(n.kind == nkElifBranch) ..< len(n):
addInheritedFieldsAux(c, check, pos, n.sons[i])
of nkSym:
incl(check, n.sym.name.id)
Expand Down
3 changes: 2 additions & 1 deletion compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,8 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
var call = newNodeI(nkCall, arg.info)
call.add(f.n.copyTree)
call.add(arg.copyTree)
result = c.semExpr(c, call)
result = c.semTryExpr(c, call)

if result != nil:
if result.typ == nil: return nil
# resulting type must be consistent with the other arguments:
Expand Down
17 changes: 13 additions & 4 deletions compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,19 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
case arg.kind
of nkEmpty..nkNilLit:
result = paDirectMapping
of nkPar, nkTupleConstr, nkCurly, nkBracket:
result = paFastAsgn
for i in 0 ..< len(arg):
if putArgInto(arg.sons[i], formal) != paDirectMapping: return
of nkDotExpr, nkDerefExpr, nkHiddenDeref, nkAddr, nkHiddenAddr:
result = putArgInto(arg[0], formal)
of nkCurly, nkBracket:
for i in 0..<arg.len:
if putArgInto(arg[i], formal) != paDirectMapping:
return paFastAsgn
result = paDirectMapping
of nkPar, nkTupleConstr, nkObjConstr:
for i in 0..<arg.len:
let a = if arg[i].kind == nkExprColonExpr: arg[i][1]
else: arg[0]
if putArgInto(a, formal) != paDirectMapping:
return paFastAsgn
result = paDirectMapping
else:
if skipTypes(formal, abstractInst).kind in {tyVar, tyLent}: result = paVarAsgn
Expand Down
6 changes: 5 additions & 1 deletion compiler/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ proc isUnsigned*(t: PType): bool =
t.skipTypes(abstractInst).kind in {tyChar, tyUInt..tyUInt64}

proc getOrdValue*(n: PNode; onError = high(Int128)): Int128 =
case n.kind
var k = n.kind
if n.typ != nil and n.typ.skipTypes(abstractInst).kind in {tyChar, tyUInt..tyUInt64}:
k = nkUIntLit

case k
of nkCharLit, nkUIntLit..nkUInt64Lit:
# XXX: enable this assert
#assert n.typ == nil or isUnsigned(n.typ), $n.typ
Expand Down
1 change: 1 addition & 0 deletions config/nim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ path="$lib/pure"
debugger:off
line_dir:off
opt:speed
define:release
@end

@if false: # not danger: # this does not work yet.
Expand Down
3 changes: 3 additions & 0 deletions doc/lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ Modules for JS backend
* `dom <dom.html>`_
Declaration of the Document Object Model for the JS backend.

* `jsconsole <jsconsole.html>`_
Wrapper for the ``console`` object.

* `jscore <jscore.html>`_
Wrapper of core JavaScript functions. For most purposes you should be using
the ``math``, ``json``, and ``times`` stdlib modules instead of this module.
Expand Down
Loading