mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
@@ -20,6 +20,7 @@ proc hasNoInit(call: PNode): bool {.inline.} =
|
||||
|
||||
proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
|
||||
callee, params: Rope) =
|
||||
genLineDir(p, ri)
|
||||
var pl = callee & ~"(" & params
|
||||
# getUniqueType() is too expensive here:
|
||||
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||
|
||||
@@ -2453,7 +2453,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
|
||||
putIntoDest(p, d, n, genLiteral(p, n))
|
||||
of nkCall, nkHiddenCallConv, nkInfix, nkPrefix, nkPostfix, nkCommand,
|
||||
nkCallStrLit:
|
||||
genLineDir(p, n)
|
||||
genLineDir(p, n) # may be redundant, it is generated in fixupCall as well
|
||||
let op = n.sons[0]
|
||||
if n.typ.isNil:
|
||||
# discard the value:
|
||||
|
||||
@@ -246,8 +246,8 @@ proc cacheGetType(tab: TypeCache; sig: SigHash): Rope =
|
||||
result = tab.getOrDefault(sig)
|
||||
|
||||
proc addAbiCheck(m: BModule, t: PType, name: Rope) =
|
||||
if isDefined(m.config, "checkabi"):
|
||||
addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [name, rope(getSize(m.config, t))])
|
||||
if isDefined(m.config, "checkabi") and (let size = getSize(m.config, t); size != szUnknownSize):
|
||||
addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [name, rope(size)])
|
||||
|
||||
proc ccgIntroducedPtr(conf: ConfigRef; s: PSym): bool =
|
||||
var pt = skipTypes(s.typ, typedescInst)
|
||||
|
||||
@@ -344,9 +344,9 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRe
|
||||
if procTokenPos == tokenPos-2 and procLink != nil:
|
||||
dispA(d.conf, result, "<a href=\"#$2\"><span class=\"Identifier\">$1</span></a>",
|
||||
"\\spanIdentifier{$1}", [rope(esc(d.target, literal)), procLink])
|
||||
elif s != nil and s.kind == skType and sfExported in s.flags and
|
||||
s.owner != nil and belongsToPackage(d.conf, s.owner) and
|
||||
d.target == outHtml:
|
||||
elif s != nil and s.kind in {skType, skVar, skLet, skConst} and
|
||||
sfExported in s.flags and s.owner != nil and
|
||||
belongsToPackage(d.conf, s.owner) and d.target == outHtml:
|
||||
let external = externalDep(d, s.owner)
|
||||
result.addf "<a href=\"$1#$2\"><span class=\"Identifier\">$3</span></a>",
|
||||
[rope changeFileExt(external, "html"), rope literal,
|
||||
|
||||
@@ -400,7 +400,8 @@ proc exprList(p: var TParser, endTok: TTokType, result: PNode) =
|
||||
proc exprColonEqExprListAux(p: var TParser, endTok: TTokType, result: PNode) =
|
||||
assert(endTok in {tkCurlyRi, tkCurlyDotRi, tkBracketRi, tkParRi})
|
||||
getTok(p)
|
||||
optInd(p, result)
|
||||
flexComment(p, result)
|
||||
optPar(p)
|
||||
# progress guaranteed
|
||||
while p.tok.tokType != endTok and p.tok.tokType != tkEof:
|
||||
var a = exprColonEqExpr(p)
|
||||
@@ -2085,7 +2086,7 @@ proc parseConstant(p: var TParser): PNode =
|
||||
addSon(result, p.emptyNode)
|
||||
eat(p, tkEquals)
|
||||
optInd(p, result)
|
||||
addSon(result, parseExpr(p))
|
||||
addSon(result, parseStmtListExpr(p))
|
||||
indAndComment(p, result)
|
||||
|
||||
proc parseBind(p: var TParser, k: TNodeKind): PNode =
|
||||
|
||||
@@ -1217,8 +1217,14 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||
else:
|
||||
put(g, tkDistinct, "distinct")
|
||||
of nkTypeDef:
|
||||
gsub(g, n, 0)
|
||||
gsub(g, n, 1)
|
||||
if n.sons[0].kind == nkPragmaExpr:
|
||||
# generate pragma after generic
|
||||
gsub(g, n.sons[0], 0)
|
||||
gsub(g, n, 1)
|
||||
gsub(g, n.sons[0], 1)
|
||||
else:
|
||||
gsub(g, n, 0)
|
||||
gsub(g, n, 1)
|
||||
put(g, tkSpaces, Space)
|
||||
if n.len > 2 and n.sons[2].kind != nkEmpty:
|
||||
putWithSpace(g, tkEquals, "=")
|
||||
|
||||
@@ -17,7 +17,7 @@ const
|
||||
byteExcess* = 128 # we use excess-K for immediates
|
||||
wordExcess* = 32768
|
||||
|
||||
MaxLoopIterations* = 3_000_000 # max iterations of all loops
|
||||
MaxLoopIterations* = 10_000_000 # max iterations of all loops
|
||||
|
||||
|
||||
type
|
||||
|
||||
@@ -442,7 +442,7 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:
|
||||
# }}}
|
||||
|
||||
proc destroyRegex(pattern: Regex) =
|
||||
pcre.free(pattern.pcreObj)
|
||||
pcre.free_substring(cast[cstring](pattern.pcreObj))
|
||||
pattern.pcreObj = nil
|
||||
if pattern.pcreExtra != nil:
|
||||
pcre.free_study(pattern.pcreExtra)
|
||||
|
||||
@@ -60,9 +60,12 @@ proc rawCompile(pattern: string, flags: cint): ptr Pcre =
|
||||
raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
|
||||
|
||||
proc finalizeRegEx(x: Regex) =
|
||||
pcre.free(x.h)
|
||||
# XXX This is a hack, but PCRE does not export its "free" function properly.
|
||||
# Sigh. The hack relies on PCRE's implementation (see ``pcre_get.c``).
|
||||
# Fortunately the implementation is unlikely to change.
|
||||
pcre.free_substring(cast[cstring](x.h))
|
||||
if not isNil(x.e):
|
||||
pcre.free_study(x.e)
|
||||
pcre.free_substring(cast[cstring](x.e))
|
||||
|
||||
proc re*(s: string, flags = {reStudy}): Regex =
|
||||
## Constructor of regular expressions.
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
## `execShellCmd proc <#execShellCmd,string>`_
|
||||
## * `parseopt module <parseopt.html>`_ for command-line parser beyond
|
||||
## `parseCmdLine proc <#parseCmdLine,string>`_
|
||||
## * `uri module <uri.html>`_
|
||||
## * `distros module <distros.html>`_
|
||||
## * `dynlib module <dynlib.html>`_
|
||||
## * `streams module <streams.html>`_
|
||||
@@ -115,13 +116,15 @@ proc joinPath*(head, tail: string): string {.
|
||||
##
|
||||
## If `head` is the empty string, `tail` is returned. If `tail` is the empty
|
||||
## string, `head` is returned with a trailing path separator. If `tail` starts
|
||||
## with a path separator it will be removed when concatenated to `head`. Other
|
||||
## path separators not located on boundaries won't be modified.
|
||||
## with a path separator it will be removed when concatenated to `head`.
|
||||
## Path separators will be normalized.
|
||||
##
|
||||
## See also:
|
||||
## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
|
||||
## * `/ proc <#/,string,string>`_
|
||||
## * `splitPath proc <#splitPath,string>`_
|
||||
## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
|
||||
## * `uri./ proc <uri.html#/,Uri,string>`_
|
||||
runnableExamples:
|
||||
when defined(posix):
|
||||
assert joinPath("usr", "lib") == "usr/lib"
|
||||
@@ -186,6 +189,8 @@ proc `/`*(head, tail: string): string {.noSideEffect.} =
|
||||
## * `joinPath(head, tail) proc <#joinPath,string,string>`_
|
||||
## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
|
||||
## * `splitPath proc <#splitPath,string>`_
|
||||
## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
|
||||
## * `uri./ proc <uri.html#/,Uri,string>`_
|
||||
runnableExamples:
|
||||
when defined(posix):
|
||||
assert "usr" / "" == "usr/"
|
||||
|
||||
@@ -29,8 +29,7 @@ const
|
||||
nativeStackTraceSupported = false
|
||||
hasSomeStackTrace = false
|
||||
|
||||
proc quitOrDebug() {.inline.} =
|
||||
quit(1)
|
||||
proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
|
||||
|
||||
proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
|
||||
sysFatal(ReraiseError, "exception handling is not available")
|
||||
|
||||
@@ -38,10 +38,15 @@ proc showErrorMessage(data: cstring) {.gcsafe.} =
|
||||
writeToStdErr(data)
|
||||
|
||||
proc quitOrDebug() {.inline.} =
|
||||
when not defined(endb):
|
||||
quit(1)
|
||||
else:
|
||||
when defined(endb):
|
||||
endbStep() # call the debugger
|
||||
elif not defined(nodejs) and not defined(nimscript):
|
||||
when nimvm:
|
||||
quit(1)
|
||||
else:
|
||||
c_abort()
|
||||
else:
|
||||
quit(1)
|
||||
|
||||
proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.}
|
||||
proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.}
|
||||
|
||||
@@ -341,8 +341,6 @@ proc compile2*(pattern: cstring,
|
||||
erroffset: ptr cint,
|
||||
tableptr: pointer): ptr Pcre
|
||||
|
||||
proc free*(p: ptr Pcre)
|
||||
|
||||
proc config*(what: cint,
|
||||
where: pointer): cint
|
||||
|
||||
|
||||
@@ -907,7 +907,7 @@ The enum B.
|
||||
<h1><a class="toc-backref" href="#8">Vars</a></h1>
|
||||
<dl class="item">
|
||||
<a id="aVariable"></a>
|
||||
<dt><pre><span class="Identifier">aVariable</span><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
|
||||
<dt><pre><a href="testproject.html#aVariable"><span class="Identifier">aVariable</span></a><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
18
tests/errmsgs/tcall_with_default_arg.nim
Normal file
18
tests/errmsgs/tcall_with_default_arg.nim
Normal file
@@ -0,0 +1,18 @@
|
||||
discard """
|
||||
outputsub: '''tcall_with_default_arg.nim(16) anotherFoo'''
|
||||
exitcode: 1
|
||||
"""
|
||||
# issue: #5604
|
||||
|
||||
proc fail() =
|
||||
raise newException(ValueError, "dead")
|
||||
|
||||
proc getDefault(): int = 123
|
||||
|
||||
proc bar*(arg1: int = getDefault()) =
|
||||
fail()
|
||||
|
||||
proc anotherFoo(input: string) =
|
||||
bar()
|
||||
|
||||
anotherFoo("123")
|
||||
@@ -58,4 +58,18 @@ block:
|
||||
var y = 2
|
||||
echo "block expression works"
|
||||
y*y
|
||||
doAssert x == 4
|
||||
doAssert x == 4
|
||||
|
||||
|
||||
# bug 10861
|
||||
macro foo(a: untyped): untyped =
|
||||
a
|
||||
|
||||
let c1 = foo:
|
||||
1 + 1
|
||||
|
||||
const c2 = foo:
|
||||
1 + 1
|
||||
|
||||
const c3 =
|
||||
foo: 1 + 1
|
||||
|
||||
Reference in New Issue
Block a user