Merge remote-tracking branch 'upstream/devel' into test-6434
This commit is contained in:
commit
e4fa1c81cb
8 changed files with 65 additions and 28 deletions
|
|
@ -1596,10 +1596,11 @@ proc genSwap(p: BProc, e: PNode, d: var TLoc) =
|
||||||
genAssignment(p, a, b, {})
|
genAssignment(p, a, b, {})
|
||||||
genAssignment(p, b, tmp, {})
|
genAssignment(p, b, tmp, {})
|
||||||
|
|
||||||
proc rdSetElemLoc(conf: ConfigRef; a: TLoc, setType: PType): Rope =
|
proc rdSetElemLoc(conf: ConfigRef; a: TLoc, typ: PType): Rope =
|
||||||
# read a location of an set element; it may need a subtraction operation
|
# read a location of an set element; it may need a subtraction operation
|
||||||
# before the set operation
|
# before the set operation
|
||||||
result = rdCharLoc(a)
|
result = rdCharLoc(a)
|
||||||
|
let setType = typ.skipTypes(abstractPtrs)
|
||||||
assert(setType.kind == tySet)
|
assert(setType.kind == tySet)
|
||||||
if firstOrd(conf, setType) != 0:
|
if firstOrd(conf, setType) != 0:
|
||||||
result = "($1- $2)" % [result, rope(firstOrd(conf, setType))]
|
result = "($1- $2)" % [result, rope(firstOrd(conf, setType))]
|
||||||
|
|
|
||||||
|
|
@ -162,9 +162,9 @@ proc mapType(conf: ConfigRef; typ: PType): TCTypeKind =
|
||||||
var base = skipTypes(typ.lastSon, typedescInst)
|
var base = skipTypes(typ.lastSon, typedescInst)
|
||||||
case base.kind
|
case base.kind
|
||||||
of tyOpenArray, tyArray, tyVarargs: result = ctPtrToArray
|
of tyOpenArray, tyArray, tyVarargs: result = ctPtrToArray
|
||||||
#of tySet:
|
of tySet:
|
||||||
# if mapSetType(base) == ctArray: result = ctPtrToArray
|
if mapSetType(conf, base) == ctArray: result = ctPtrToArray
|
||||||
# else: result = ctPtr
|
else: result = ctPtr
|
||||||
# XXX for some reason this breaks the pegs module
|
# XXX for some reason this breaks the pegs module
|
||||||
else: result = ctPtr
|
else: result = ctPtr
|
||||||
of tyPointer: result = ctPtr
|
of tyPointer: result = ctPtr
|
||||||
|
|
@ -641,10 +641,11 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
||||||
compileToCpp(m): "&" else: "*"
|
compileToCpp(m): "&" else: "*"
|
||||||
var et = origTyp.skipTypes(abstractInst).lastSon
|
var et = origTyp.skipTypes(abstractInst).lastSon
|
||||||
var etB = et.skipTypes(abstractInst)
|
var etB = et.skipTypes(abstractInst)
|
||||||
if etB.kind in {tyArray, tyOpenArray, tyVarargs}:
|
if mapType(m.config, t) == ctPtrToArray:
|
||||||
# this is correct! sets have no proper base type, so we treat
|
if etB.kind == tySet:
|
||||||
# ``var set[char]`` in `getParamTypeDesc`
|
et = getSysType(m.g.graph, unknownLineInfo(), tyUInt8)
|
||||||
et = elemType(etB)
|
else:
|
||||||
|
et = elemType(etB)
|
||||||
etB = et.skipTypes(abstractInst)
|
etB = et.skipTypes(abstractInst)
|
||||||
star[0] = '*'
|
star[0] = '*'
|
||||||
case etB.kind
|
case etB.kind
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ proc canon(x: string; result: var string; state: var int) =
|
||||||
if d > 0: setLen(result, d-1)
|
if d > 0: setLen(result, d-1)
|
||||||
elif isDot(x, b):
|
elif isDot(x, b):
|
||||||
discard "discard the dot"
|
discard "discard the dot"
|
||||||
elif b[1] > b[0]:
|
elif b[1] >= b[0]:
|
||||||
if result.len > 0 and result[^1] != DirSep:
|
if result.len > 0 and result[^1] != DirSep:
|
||||||
result.add DirSep
|
result.add DirSep
|
||||||
result.add substr(x, b[0], b[1])
|
result.add substr(x, b[0], b[1])
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,13 @@ proc `$`*(t: typedesc): string =
|
||||||
## An alias for `name`.
|
## An alias for `name`.
|
||||||
name(t)
|
name(t)
|
||||||
|
|
||||||
proc arity*(t: typedesc): int {.magic: "TypeTrait".}
|
proc arity*(t: typedesc): int {.magic: "TypeTrait".} =
|
||||||
## Returns the arity of the given type
|
## Returns the arity of the given type. This is the number of "type" components or
|
||||||
|
## the number of generic parameters a given type ``t`` has.
|
||||||
|
runnableExamples:
|
||||||
|
assert arity(seq[string]) == 1
|
||||||
|
assert arity(array[3, int]) == 2
|
||||||
|
assert arity((int, int, float, string)) == 4
|
||||||
|
|
||||||
proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
||||||
## Accepts an instantiated generic type and returns its
|
## Accepts an instantiated generic type and returns its
|
||||||
|
|
@ -47,11 +52,11 @@ proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
||||||
## seq[int].genericHead[float] will be seq[float]
|
## seq[int].genericHead[float] will be seq[float]
|
||||||
##
|
##
|
||||||
## A compile-time error will be produced if the supplied type
|
## A compile-time error will be produced if the supplied type
|
||||||
## is not generic
|
## is not generic.
|
||||||
|
|
||||||
proc stripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
proc stripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
||||||
## This trait is similar to `genericHead`, but instead of producing
|
## This trait is similar to `genericHead`, but instead of producing
|
||||||
## error for non-generic types, it will just return them unmodified
|
## error for non-generic types, it will just return them unmodified.
|
||||||
|
|
||||||
proc supportsCopyMem*(t: typedesc): bool {.magic: "TypeTrait".}
|
proc supportsCopyMem*(t: typedesc): bool {.magic: "TypeTrait".}
|
||||||
## This trait returns true iff the type ``t`` is safe to use for
|
## This trait returns true iff the type ``t`` is safe to use for
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,9 @@ proc readLine(f: File, line: var TaintedString): bool =
|
||||||
var pos = 0
|
var pos = 0
|
||||||
|
|
||||||
# Use the currently reserved space for a first try
|
# Use the currently reserved space for a first try
|
||||||
var sp = line.string.len
|
var sp = max(line.string.len, 80)
|
||||||
if sp == 0:
|
line.string.setLen(sp)
|
||||||
sp = 80
|
|
||||||
line.string.setLen(sp)
|
|
||||||
while true:
|
while true:
|
||||||
# memset to \L so that we can tell how far fgets wrote, even on EOF, where
|
# memset to \L so that we can tell how far fgets wrote, even on EOF, where
|
||||||
# fgets doesn't append an \L
|
# fgets doesn't append an \L
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,31 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''
|
output: '''true'''
|
||||||
tfailedassert_stacktrace.nim(16) tfailedassert_stacktrace
|
|
||||||
tfailedassert_stacktrace.nim(15) foo
|
|
||||||
system.nim(3778) failedAssertImpl
|
|
||||||
system.nim(3771) raiseAssert
|
|
||||||
system.nim(2818) sysFatal
|
|
||||||
'''
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
const expected = """
|
||||||
|
tfailedassert_stacktrace.nim(34) tfailedassert_stacktrace
|
||||||
|
tfailedassert_stacktrace.nim(33) foo
|
||||||
|
system.nim(*) failedAssertImpl
|
||||||
|
system.nim(*) raiseAssert
|
||||||
|
system.nim(*) sysFatal"""
|
||||||
|
|
||||||
|
proc tmatch(x, p: string): bool =
|
||||||
|
var i = 0
|
||||||
|
var k = 0
|
||||||
|
while i < p.len:
|
||||||
|
if p[i] == '*':
|
||||||
|
let oldk = k
|
||||||
|
while k < x.len and x[k] in {'0'..'9'}: inc k
|
||||||
|
# no digit skipped?
|
||||||
|
if oldk == k: return false
|
||||||
|
inc i
|
||||||
|
elif k < x.len and p[i] == x[k]:
|
||||||
|
inc i
|
||||||
|
inc k
|
||||||
|
else:
|
||||||
|
return false
|
||||||
|
while k < x.len and x[k] in {' ', '\L', '\C'}: inc k
|
||||||
|
result = i >= p.len and k >= x.len
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -16,4 +34,5 @@ try:
|
||||||
foo()
|
foo()
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
let e = getCurrentException()
|
let e = getCurrentException()
|
||||||
echo e.getStackTrace
|
let trace = e.getStackTrace
|
||||||
|
echo tmatch(trace, expected)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ string 3'''
|
||||||
# bug #5532
|
# bug #5532
|
||||||
import os, asyncfile, asyncdispatch
|
import os, asyncfile, asyncdispatch
|
||||||
|
|
||||||
removeFile("test.txt")
|
const F = "test_async.txt"
|
||||||
let f = openAsync("test.txt", fmWrite)
|
|
||||||
|
removeFile(F)
|
||||||
|
let f = openAsync(F, fmWrite)
|
||||||
var futs = newSeq[Future[void]]()
|
var futs = newSeq[Future[void]]()
|
||||||
for i in 1..3:
|
for i in 1..3:
|
||||||
futs.add(f.write("string " & $i & "\n"))
|
futs.add(f.write("string " & $i & "\n"))
|
||||||
waitFor(all(futs))
|
waitFor(all(futs))
|
||||||
f.close()
|
f.close()
|
||||||
echo readFile("test.txt")
|
echo readFile(F)
|
||||||
|
|
||||||
|
|
|
||||||
10
tests/ccgbugs/t8967.nim
Normal file
10
tests/ccgbugs/t8967.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
targets: "c cpp"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import marshal
|
||||||
|
|
||||||
|
let orig: set[char] = {'A'..'Z'}
|
||||||
|
let m = $$orig
|
||||||
|
let old = to[set[char]](m)
|
||||||
|
doAssert orig - old == {}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue