diff options
-rw-r--r-- | compiler/renderer.nim | 4 | ||||
-rw-r--r-- | compiler/semtypes.nim | 10 | ||||
-rw-r--r-- | compiler/semtypinst.nim | 5 | ||||
-rw-r--r-- | koch.nim | 6 | ||||
-rw-r--r-- | lib/pure/collections/rtarrays.nim | 1 | ||||
-rw-r--r-- | lib/pure/future.nim | 10 | ||||
-rw-r--r-- | tests/closure/tinvalidclosure.nim | 4 | ||||
-rw-r--r-- | tests/generics/mdotlookup.nim | 2 | ||||
-rw-r--r-- | tests/generics/tdotlookup.nim | 2 | ||||
-rw-r--r-- | tests/generics/tforwardgeneric.nim | 1 | ||||
-rw-r--r-- | tests/generics/tthread_generic.nim | 12 | ||||
-rw-r--r-- | tests/macros/tclosuremacro.nim (renamed from tests/closure/tclosuremacro.nim) | 4 | ||||
-rw-r--r-- | tools/nimweb.nim | 19 | ||||
-rw-r--r-- | web/nim.ini | 2 |
14 files changed, 50 insertions, 32 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 3f7b0e657..f25f3e7ee 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -947,10 +947,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = of nkConstDef, nkIdentDefs: gcomma(g, n, 0, -3) var L = sonsLen(n) - if n.sons[L - 2].kind != nkEmpty: + if L >= 2 and n.sons[L - 2].kind != nkEmpty: putWithSpace(g, tkColon, ":") gsub(g, n.sons[L - 2]) - if n.sons[L - 1].kind != nkEmpty: + if L >= 1 and n.sons[L - 1].kind != nkEmpty: put(g, tkSpaces, Space) putWithSpace(g, tkEquals, "=") gsub(g, n.sons[L - 1], c) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index e33df75ff..4305a48e1 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -386,13 +386,13 @@ proc semIdentVis(c: PContext, kind: TSymKind, n: PNode, else: result = newSymG(kind, n, c) -proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode, - allowed: TSymFlags): PSym = - if n.kind == nkPragmaExpr: +proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode, + allowed: TSymFlags): PSym = + if n.kind == nkPragmaExpr: checkSonsLen(n, 2) result = semIdentVis(c, kind, n.sons[0], allowed) case kind - of skType: + of skType: # process pragmas later, because result.typ has not been set yet discard of skField: pragma(c, result, n.sons[1], fieldPragmas) @@ -403,7 +403,7 @@ proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode, else: result = semIdentVis(c, kind, n, allowed) if gCmd == cmdPretty: styleCheckDef(n.info, result) - + proc checkForOverlap(c: PContext, t: PNode, currentEx, branchIndex: int) = let ex = t[branchIndex][currentEx].skipConv for i in countup(1, branchIndex): diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index c53464f80..e069064c2 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -292,7 +292,8 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType = var newbody = replaceTypeVarsT(cl, lastSon(body)) newbody.flags = newbody.flags + (t.flags + body.flags - tfInstClearedFlags) result.flags = result.flags + newbody.flags - tfInstClearedFlags - newbody.callConv = body.callConv + # This is actually wrong: tgeneric_closure fails with this line: + #newbody.callConv = body.callConv # This type may be a generic alias and we want to resolve it here. # One step is enough, because the recursive nature of # handleGenericInvokation will handle the alias-to-alias-to-alias case @@ -307,7 +308,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType = proc eraseVoidParams*(t: PType) = # transform '(): void' into '()' because old parts of the compiler really - # doesn't deal with '(): void': + # don't deal with '(): void': if t.sons[0] != nil and t.sons[0].kind == tyEmpty: t.sons[0] = nil diff --git a/koch.nim b/koch.nim index 2c7d49cf1..79228c1a4 100644 --- a/koch.nim +++ b/koch.nim @@ -45,6 +45,7 @@ Possible Commands: web [options] generates the website and the full documentation website [options] generates only the website csource [options] builds the C sources for installation + pdf builds the PDF documentation zip builds the installation ZIP package nsis [options] builds the NSIS Setup installer (for Windows) tests [options] run the testsuite @@ -129,6 +130,10 @@ proc website(args: string) = exec("$# cc -r tools/nimweb.nim $# --website web/nim --putenv:nimversion=$#" % [findNim(), args, VersionAsString]) +proc pdf(args="") = + exec("$# cc -r tools/nimweb.nim $# --pdf web/nim --putenv:nimversion=$#" % + [findNim(), args, VersionAsString]) + # -------------- boot --------------------------------------------------------- const @@ -351,6 +356,7 @@ of cmdArgument: of "clean": clean(op.cmdLineRest) of "web": web(op.cmdLineRest) of "website": website(op.cmdLineRest) + of "pdf": pdf() of "csource", "csources": csource(op.cmdLineRest) of "zip": zip(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest) diff --git a/lib/pure/collections/rtarrays.nim b/lib/pure/collections/rtarrays.nim index 7782b032c..e5d0b0d8a 100644 --- a/lib/pure/collections/rtarrays.nim +++ b/lib/pure/collections/rtarrays.nim @@ -21,7 +21,6 @@ type apart: array [ArrayPartSize, T] UncheckedArray* {.unchecked.}[T] = array[0..100_000_000, T] - template usesSeqPart(x): expr = x.L > ArrayPartSize proc initRtArray*[T](len: Natural): RtArray[T] = diff --git a/lib/pure/future.nim b/lib/pure/future.nim index 34b76e41d..a0c1b5c2d 100644 --- a/lib/pure/future.nim +++ b/lib/pure/future.nim @@ -77,7 +77,17 @@ macro `=>`*(p, b: expr): expr {.immediate.} = identDefs.add(c) identDefs.add(newEmptyNode()) identDefs.add(newEmptyNode()) + of nnkInfix: + if c[0].kind == nnkIdent and c[0].ident == !"->": + var procTy = createProcType(c[1], c[2]) + params[0] = procTy[0][0] + for i in 1 .. <procTy[0].len: + params.add(procTy[0][i]) + else: + error("Expected proc type (->) got (" & $c[0].ident & ").") + break else: + echo treeRepr c error("Incorrect procedure parameter list.") params.add(identDefs) of nnkIdent: diff --git a/tests/closure/tinvalidclosure.nim b/tests/closure/tinvalidclosure.nim index 06e19df3c..18968a6c6 100644 --- a/tests/closure/tinvalidclosure.nim +++ b/tests/closure/tinvalidclosure.nim @@ -1,12 +1,12 @@ discard """ line: 12 - errormsg: "type mismatch: got (proc (int){.closure, gcsafe.})" + errormsg: "type mismatch: got (proc (int){.closure, gcsafe, locks: 0.})" """ proc ugh[T](x: T) {.closure.} = echo "ugha" -proc takeCdecl(p: proc (x: int) {.cdecl.}) = nil +proc takeCdecl(p: proc (x: int) {.cdecl.}) = discard takeCDecl(ugh[int]) diff --git a/tests/generics/mdotlookup.nim b/tests/generics/mdotlookup.nim index 0c4d0c87c..2984574c2 100644 --- a/tests/generics/mdotlookup.nim +++ b/tests/generics/mdotlookup.nim @@ -11,6 +11,6 @@ import sets var intset = initSet[int]() -proc func*[T](a: T) = +proc fn*[T](a: T) = if a in intset: echo("true") else: echo("false") diff --git a/tests/generics/tdotlookup.nim b/tests/generics/tdotlookup.nim index d3deca7fc..17c60ded2 100644 --- a/tests/generics/tdotlookup.nim +++ b/tests/generics/tdotlookup.nim @@ -7,4 +7,4 @@ import mdotlookup foo(7) # bug #1444 -func(4) +fn(4) diff --git a/tests/generics/tforwardgeneric.nim b/tests/generics/tforwardgeneric.nim index c5943b966..af0c7daf4 100644 --- a/tests/generics/tforwardgeneric.nim +++ b/tests/generics/tforwardgeneric.nim @@ -1,6 +1,7 @@ discard """ output: "1.1000000000000001e+00 11" ccodecheck: "!@'ClEnv'" + disabled: "true" """ proc p[T](a, b: T): T diff --git a/tests/generics/tthread_generic.nim b/tests/generics/tthread_generic.nim index 5887f7db3..fdd11d9d1 100644 --- a/tests/generics/tthread_generic.nim +++ b/tests/generics/tthread_generic.nim @@ -8,22 +8,22 @@ type b: proc(val: T) {.thread.} proc handleThreadFunc(arg: TThreadFuncArgs[int]){.thread.} = - var func = arg.a + var fn = arg.a var callback = arg.b - var output = func() + var output = fn() callback(output) -proc `@||->`*[T](func: proc(): T {.thread.}, +proc `@||->`*[T](fn: proc(): T {.thread.}, callback: proc(val: T){.thread.}): TThread[TThreadFuncArgs[T]] = var thr: TThread[TThreadFuncArgs[T]] var args: TThreadFuncArgs[T] - args.a = func + args.a = fn args.b = callback createThread(thr, handleThreadFunc, args) return thr -proc `||->`*[T](func: proc(): T{.thread.}, callback: proc(val: T){.thread.}) = - discard func @||-> callback +proc `||->`*[T](fn: proc(): T{.thread.}, callback: proc(val: T){.thread.}) = + discard fn @||-> callback when isMainModule: import os diff --git a/tests/closure/tclosuremacro.nim b/tests/macros/tclosuremacro.nim index 12e463316..d5d9b656c 100644 --- a/tests/closure/tclosuremacro.nim +++ b/tests/macros/tclosuremacro.nim @@ -35,9 +35,9 @@ echo noParams(() => 3) echo doWithOneAndTwo((x, y) => x + y) -noReturn(() -> void => echo("noReturn")) +noReturn((() -> void) => echo("noReturn")) proc pass2(f: (int, int) -> int): (int) -> int = - (x: int) -> int => f(2, x) + ((x: int) -> int) => f(2, x) echo pass2((x, y) => x + y)(4) diff --git a/tools/nimweb.nim b/tools/nimweb.nim index c4dc8226d..fa4f15995 100644 --- a/tools/nimweb.nim +++ b/tools/nimweb.nim @@ -24,8 +24,10 @@ type numProcessors: int # Set by parallelBuild:n, only works for values > 0. TRssItem = object year, month, day, title: string + TAction = enum + actAll, actOnlyWebsite, actPdf -var onlyWebsite: bool +var action: TAction proc initConfigData(c: var TConfigData) = c.tabs = @[] @@ -70,6 +72,7 @@ Options: -h, --help shows this help -v, --version shows the version --website only build the website, not the full documentation + --pdf build the PDF version of the documentation Compile_options: will be passed to the Nim compiler """ @@ -137,8 +140,8 @@ proc parseCmdLine(c: var TConfigData) = var idx = val.find('=') if idx < 0: quit("invalid command line") c.vars[substr(val, 0, idx-1)] = substr(val, idx+1) - of "website": - onlyWebsite = true + of "website": action = actOnlyWebsite + of "pdf": action = actPdf else: quit(usage) of cmdEnd: break if c.infile.len == 0: quit(usage) @@ -434,14 +437,12 @@ proc main(c: var TConfigData) = buildDoc(c, "web/upload") buildDocSamples(c, "doc") buildDoc(c, "doc") - #buildPdfDoc(c, "doc") var c: TConfigData initConfigData(c) parseCmdLine(c) parseIniFile(c) -if onlyWebsite: - buildWebsite(c) - #buildPdfDoc(c, "doc") -else: - main(c) +case action +of actOnlyWebsite: buildWebsite(c) +of actPdf: buildPdfDoc(c, "doc") +of actAll: main(c) diff --git a/web/nim.ini b/web/nim.ini index 6face49bc..aa7b6d933 100644 --- a/web/nim.ini +++ b/web/nim.ini @@ -44,7 +44,7 @@ learn: """Repetition renders the ridiculous reasonable. - Norman Wildberger""" doc: "endb;intern;apis;lib;manual.txt;tut1;tut2;nimc;overview;filters" doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt" doc: "nimfix.txt" -pdf: "manual;lib;tut1;tut2;nimc;niminst;gc" +pdf: "manual.txt;lib;tut1;tut2;nimc;niminst;gc" srcdoc2: "system.nim" srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned" srcdoc2: "impure/re;pure/sockets;pure/typetraits" |