Merge branch 'devel' of https://github.com/nim-lang/Nim into devel
This commit is contained in:
commit
dda01cb726
13 changed files with 218 additions and 1099 deletions
|
|
@ -1636,7 +1636,10 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of nkSym:
|
of nkSym:
|
||||||
genSym(p, n, r)
|
genSym(p, n, r)
|
||||||
of nkCharLit..nkInt64Lit:
|
of nkCharLit..nkInt64Lit:
|
||||||
r.res = rope(n.intVal)
|
if n.typ.kind == tyBool:
|
||||||
|
r.res = if n.intVal == 0: rope"false" else: rope"true"
|
||||||
|
else:
|
||||||
|
r.res = rope(n.intVal)
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
of nkNilLit:
|
of nkNilLit:
|
||||||
if isEmptyType(n.typ):
|
if isEmptyType(n.typ):
|
||||||
|
|
|
||||||
1096
lib/pure/redis.nim
1096
lib/pure/redis.nim
File diff suppressed because it is too large
Load diff
|
|
@ -259,8 +259,10 @@ when not defined(useNimRtl):
|
||||||
of tyInt16: add result, $int(cast[ptr int16](p)[])
|
of tyInt16: add result, $int(cast[ptr int16](p)[])
|
||||||
of tyInt32: add result, $int(cast[ptr int32](p)[])
|
of tyInt32: add result, $int(cast[ptr int32](p)[])
|
||||||
of tyInt64: add result, $(cast[ptr int64](p)[])
|
of tyInt64: add result, $(cast[ptr int64](p)[])
|
||||||
of tyUInt8: add result, $ze(cast[ptr int8](p)[])
|
of tyUInt8: add result, $(cast[ptr uint8](p)[])
|
||||||
of tyUInt16: add result, $ze(cast[ptr int16](p)[])
|
of tyUInt16: add result, $(cast[ptr uint16](p)[])
|
||||||
|
of tyUInt32: add result, $(cast[ptr uint32](p)[])
|
||||||
|
of tyUInt64: add result, $(cast[ptr uint64](p)[])
|
||||||
|
|
||||||
of tyFloat: add result, $(cast[ptr float](p)[])
|
of tyFloat: add result, $(cast[ptr float](p)[])
|
||||||
of tyFloat32: add result, $(cast[ptr float32](p)[])
|
of tyFloat32: add result, $(cast[ptr float32](p)[])
|
||||||
|
|
|
||||||
15
tests/closure/tclosureinference3304.nim
Normal file
15
tests/closure/tclosureinference3304.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
discard """
|
||||||
|
output: '''@[1, 2, 5]'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
import future, sequtils
|
||||||
|
|
||||||
|
type
|
||||||
|
List[T] = ref object
|
||||||
|
val: T
|
||||||
|
|
||||||
|
proc foo[T](l: List[T]): seq[int] =
|
||||||
|
@[1,2,3,5].filter(x => x != l.val)
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
echo(foo(List[int](val: 3)))
|
||||||
9
tests/closure/tcodegenerr1923.nim
Normal file
9
tests/closure/tcodegenerr1923.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
type
|
||||||
|
Foo[M] = proc() : M
|
||||||
|
|
||||||
|
proc bar[M](f : Foo[M]) =
|
||||||
|
discard f()
|
||||||
|
|
||||||
|
proc baz() : int = 42
|
||||||
|
|
||||||
|
bar(baz)
|
||||||
10
tests/closure/tfutclosure2138.nim
Normal file
10
tests/closure/tfutclosure2138.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import future, sequtils
|
||||||
|
|
||||||
|
proc any[T](list: varargs[T], pred: (T) -> bool): bool =
|
||||||
|
for item in list:
|
||||||
|
if pred(item):
|
||||||
|
result = true
|
||||||
|
break
|
||||||
|
|
||||||
|
proc contains(s: string, words: varargs[string]): bool =
|
||||||
|
any(words, (word) => s.contains(word))
|
||||||
6
tests/closure/tissue1502def.nim
Normal file
6
tests/closure/tissue1502def.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import sequtils
|
||||||
|
let xs: seq[tuple[key: string, val: seq[string]]] = @[("foo", @["bar"])]
|
||||||
|
|
||||||
|
let maps = xs.map(
|
||||||
|
proc(x: auto): tuple[typ: string, maps: seq[string]] =
|
||||||
|
(x.key, x.val.map(proc(x: string): string = x)))
|
||||||
3
tests/closure/tissue1642.nim
Normal file
3
tests/closure/tissue1642.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
block:
|
||||||
|
var i = 0
|
||||||
|
proc p() = inc(i)
|
||||||
16
tests/closure/tissue1846.nim
Normal file
16
tests/closure/tissue1846.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
type
|
||||||
|
TBinOp*[T] = proc (x,y: T): bool
|
||||||
|
|
||||||
|
THeap*[T] = object
|
||||||
|
cmp*: TBinOp[T]
|
||||||
|
|
||||||
|
proc less*[T](x,y: T): bool =
|
||||||
|
x < y
|
||||||
|
|
||||||
|
proc initHeap*[T](cmp: TBinOp[T]): THeap[T] =
|
||||||
|
result.cmp = cmp
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
var h = initHeap[int](less[int])
|
||||||
|
|
||||||
|
echo h.cmp(2,3)
|
||||||
7
tests/closure/tissue1911.nim
Normal file
7
tests/closure/tissue1911.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
proc foo(x: int) : auto =
|
||||||
|
|
||||||
|
proc helper() : int = x
|
||||||
|
proc bar() : int = helper()
|
||||||
|
proc baz() : int = helper()
|
||||||
|
|
||||||
|
return (bar, baz)
|
||||||
4
tests/closure/tissue600.nim
Normal file
4
tests/closure/tissue600.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
for i in 1..1:
|
||||||
|
var reported = false
|
||||||
|
proc report() =
|
||||||
|
reported = true
|
||||||
137
tests/closure/tmacrobust1512.nim
Normal file
137
tests/closure/tmacrobust1512.nim
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
import macros, strutils
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/issues/1512
|
||||||
|
|
||||||
|
proc macrobust0 (raw_input: string) =
|
||||||
|
var output = ""
|
||||||
|
proc p1 (a:string) =
|
||||||
|
output.add (a)
|
||||||
|
|
||||||
|
proc p2 (a:string) = p1 (a)
|
||||||
|
proc p3 (a:string) = p2 (a)
|
||||||
|
proc p4 (a:string) = p3 (a)
|
||||||
|
proc p5 (a:string) = p4 (a)
|
||||||
|
proc p6 (a:string) = p5 (a)
|
||||||
|
proc p7 (a:string) = p6 (a)
|
||||||
|
proc p8 (a:string) = p7 (a)
|
||||||
|
proc p9 (a:string) = p8 (a)
|
||||||
|
proc p10 (a:string) = p9 (a)
|
||||||
|
proc p11 (a:string) = p10 (a)
|
||||||
|
proc p12 (a:string) = p11 (a)
|
||||||
|
proc p13 (a:string) = p12 (a)
|
||||||
|
proc p14 (a:string) = p13 (a)
|
||||||
|
proc p15 (a:string) = p14 (a)
|
||||||
|
proc p16 (a:string) = p15 (a)
|
||||||
|
proc p17 (a:string) = p16 (a)
|
||||||
|
proc p18 (a:string) = p17 (a)
|
||||||
|
proc p19 (a:string) = p18 (a)
|
||||||
|
proc p20 (a:string) = p19 (a)
|
||||||
|
|
||||||
|
let input = $raw_input
|
||||||
|
|
||||||
|
for a in input.split ():
|
||||||
|
p20 (a)
|
||||||
|
p19 (a)
|
||||||
|
|
||||||
|
|
||||||
|
p18 (a)
|
||||||
|
p17 (a)
|
||||||
|
p16 (a)
|
||||||
|
p15 (a)
|
||||||
|
p14 (a)
|
||||||
|
p13 (a)
|
||||||
|
p12 (a)
|
||||||
|
p11 (a)
|
||||||
|
p10 (a)
|
||||||
|
p9 (a)
|
||||||
|
p8 (a)
|
||||||
|
p7 (a)
|
||||||
|
p6 (a)
|
||||||
|
p5 (a)
|
||||||
|
p4 (a)
|
||||||
|
p3 (a)
|
||||||
|
p2 (a)
|
||||||
|
p1 (a)
|
||||||
|
|
||||||
|
|
||||||
|
echo output
|
||||||
|
|
||||||
|
macro macrobust (raw_input: expr) : stmt =
|
||||||
|
|
||||||
|
var output = ""
|
||||||
|
proc p1 (a:string) =
|
||||||
|
output.add (a)
|
||||||
|
|
||||||
|
proc p2 (a:string) = p1 (a)
|
||||||
|
proc p3 (a:string) = p2 (a)
|
||||||
|
proc p4 (a:string) = p3 (a)
|
||||||
|
proc p5 (a:string) = p4 (a)
|
||||||
|
proc p6 (a:string) = p5 (a)
|
||||||
|
proc p7 (a:string) = p6 (a)
|
||||||
|
proc p8 (a:string) = p7 (a)
|
||||||
|
proc p9 (a:string) = p8 (a)
|
||||||
|
proc p10 (a:string) = p9 (a)
|
||||||
|
proc p11 (a:string) = p10 (a)
|
||||||
|
proc p12 (a:string) = p11 (a)
|
||||||
|
proc p13 (a:string) = p12 (a)
|
||||||
|
proc p14 (a:string) = p13 (a)
|
||||||
|
proc p15 (a:string) = p14 (a)
|
||||||
|
proc p16 (a:string) = p15 (a)
|
||||||
|
proc p17 (a:string) = p16 (a)
|
||||||
|
proc p18 (a:string) = p17 (a)
|
||||||
|
proc p19 (a:string) = p18 (a)
|
||||||
|
proc p20 (a:string) = p19 (a)
|
||||||
|
|
||||||
|
let input = $raw_input
|
||||||
|
|
||||||
|
for a in input.split ():
|
||||||
|
p20 (a)
|
||||||
|
p19 (a)
|
||||||
|
|
||||||
|
p18 (a)
|
||||||
|
p17 (a)
|
||||||
|
p16 (a)
|
||||||
|
p15 (a)
|
||||||
|
p14 (a)
|
||||||
|
p13 (a)
|
||||||
|
p12 (a)
|
||||||
|
p11 (a)
|
||||||
|
p10 (a)
|
||||||
|
p9 (a)
|
||||||
|
p8 (a)
|
||||||
|
p7 (a)
|
||||||
|
p6 (a)
|
||||||
|
p5 (a)
|
||||||
|
p4 (a)
|
||||||
|
p3 (a)
|
||||||
|
p2 (a)
|
||||||
|
|
||||||
|
echo output
|
||||||
|
discard result
|
||||||
|
|
||||||
|
macrobust """
|
||||||
|
fdsasadfsdfa sadfsdafsdaf
|
||||||
|
dsfsdafdsfadsfa fsdaasdfasdf
|
||||||
|
fsdafsadfsad asdfasdfasdf
|
||||||
|
fdsasdfasdfa sadfsadfsadf
|
||||||
|
sadfasdfsdaf sadfsdafsdaf dsfasdaf
|
||||||
|
sadfsdafsadf fdsasdafsadf fdsasadfsdaf
|
||||||
|
sdfasadfsdafdfsa sadfsadfsdaf
|
||||||
|
sdafsdaffsda sdfasadfsadf
|
||||||
|
fsdasdafsdfa sdfasdfafsda
|
||||||
|
sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
macrobust0 """
|
||||||
|
fdsasadfsdfa sadfsdafsdaf
|
||||||
|
dsfsdafdsfadsfa fsdaasdfasdf
|
||||||
|
fsdafsadfsad asdfasdfasdf
|
||||||
|
fdsasdfasdfa sadfsadfsadf
|
||||||
|
sadfasdfsdaf sadfsdafsdaf dsfasdaf
|
||||||
|
sadfsdafsadf fdsasdafsadf fdsasadfsdaf
|
||||||
|
sdfasadfsdafdfsa sadfsadfsdaf
|
||||||
|
sdafsdaffsda sdfasadfsadf
|
||||||
|
fsdasdafsdfa sdfasdfafsda
|
||||||
|
sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
|
||||||
|
"""
|
||||||
|
|
@ -21,6 +21,9 @@ News
|
||||||
the language.
|
the language.
|
||||||
- Top level routines cannot have the calling convention ``closure``
|
- Top level routines cannot have the calling convention ``closure``
|
||||||
anymore.
|
anymore.
|
||||||
|
- The ``redis`` module has been moved out of the standard library. It can
|
||||||
|
now be installed via Nimble and is located here:
|
||||||
|
https://github.com/nim-lang/redis
|
||||||
|
|
||||||
|
|
||||||
Syntax changes
|
Syntax changes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue