Merge branch 'devel' into araq-devel
This commit is contained in:
commit
e455023902
18 changed files with 175 additions and 64 deletions
12
tests/concepts/t7952.nim
Normal file
12
tests/concepts/t7952.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
discard """
|
||||
output: 5
|
||||
"""
|
||||
|
||||
type
|
||||
HasLen = concept iter
|
||||
len(iter) is int
|
||||
|
||||
proc echoLen(x: HasLen) =
|
||||
echo len(x)
|
||||
|
||||
echoLen([1, 2, 3, 4, 5])
|
||||
|
|
@ -151,3 +151,13 @@ if true:
|
|||
fooBool()
|
||||
else:
|
||||
raise newException(ValueError, "argh")
|
||||
|
||||
# bug #5374
|
||||
|
||||
proc test1(): int64 {.discardable.} = discard
|
||||
proc test2(): int {.discardable.} = discard
|
||||
|
||||
if true:
|
||||
test1()
|
||||
else:
|
||||
test2()
|
||||
|
|
|
|||
7
tests/iter/t8041.nim
Normal file
7
tests/iter/t8041.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
iterator xy[T](a: T, b: set[T]): T =
|
||||
if a in b:
|
||||
yield a
|
||||
|
||||
for a in xy(1'i8, {}):
|
||||
for b in xy(a, {}):
|
||||
echo a
|
||||
|
|
@ -137,4 +137,12 @@ block:
|
|||
static:
|
||||
assert hasIntSerKey
|
||||
assert strSerKey == "string"
|
||||
assert nestedItemDefVal == "Nimmers of the world, unite!"
|
||||
assert nestedItemDefVal == "Nimmers of the world, unite!"
|
||||
|
||||
block:
|
||||
template simpleAttr {.pragma.}
|
||||
|
||||
type Annotated {.simpleAttr.} = object
|
||||
|
||||
proc generic_proc[T]() =
|
||||
assert Annotated.hasCustomPragma(simpleAttr)
|
||||
6
tests/sets/t2669.nim
Normal file
6
tests/sets/t2669.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
discard """
|
||||
line: 6
|
||||
errormsg: "cannot convert 6 to range 1..5(int8)"
|
||||
"""
|
||||
|
||||
var c: set[range[1i8..5i8]] = {1i8, 2i8, 6i8}
|
||||
|
|
@ -89,4 +89,62 @@ block:
|
|||
proc f(size: int): int =
|
||||
var some = newStringOfCap(size)
|
||||
result = size
|
||||
doAssert f(4) == 4
|
||||
doAssert f(4) == 4
|
||||
|
||||
# #6689
|
||||
block:
|
||||
static:
|
||||
proc foo(): int = 0
|
||||
var f: proc(): int
|
||||
doAssert f.isNil
|
||||
f = foo
|
||||
doAssert(not f.isNil)
|
||||
|
||||
block:
|
||||
static:
|
||||
var x: ref ref int
|
||||
new(x)
|
||||
doAssert(not x.isNil)
|
||||
|
||||
# #7871
|
||||
static:
|
||||
type Obj = object
|
||||
field: int
|
||||
var s = newSeq[Obj](1)
|
||||
var o = Obj()
|
||||
s[0] = o
|
||||
o.field = 2
|
||||
doAssert s[0].field == 0
|
||||
|
||||
# #8125
|
||||
static:
|
||||
let def_iter_var = ident("it")
|
||||
|
||||
# #8142
|
||||
static:
|
||||
type Obj = object
|
||||
names: string
|
||||
|
||||
proc pushName(o: var Obj) =
|
||||
var s = ""
|
||||
s.add("FOOBAR")
|
||||
o.names.add(s)
|
||||
|
||||
var o = Obj()
|
||||
o.names = ""
|
||||
o.pushName()
|
||||
o.pushName()
|
||||
doAssert o.names == "FOOBARFOOBAR"
|
||||
|
||||
# #8154
|
||||
import parseutils
|
||||
|
||||
static:
|
||||
type Obj = object
|
||||
i: int
|
||||
|
||||
proc foo(): Obj =
|
||||
discard parseInt("1", result.i, 0)
|
||||
|
||||
static:
|
||||
doAssert foo().i == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue