use 'using' instead of 'sig' keyword; cleans up new features a bit
This commit is contained in:
parent
554a3e9335
commit
c9966a3e17
20 changed files with 109 additions and 74 deletions
|
|
@ -11,7 +11,7 @@ discard """
|
|||
type
|
||||
E = enum A, B, C
|
||||
|
||||
proc foo(x): auto =
|
||||
proc foo(x: int): auto =
|
||||
return case x
|
||||
of 1..9: "digit"
|
||||
else: "number"
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ discard """
|
|||
line: 6
|
||||
"""
|
||||
|
||||
let x = proc (x, y): auto = x + y
|
||||
let x = proc (x, y: auto): auto = x + y
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ proc foo[T](p: TType[T, range[0..2]]) =
|
|||
|
||||
#bug #1366
|
||||
|
||||
proc reversed(x) =
|
||||
proc reversed(x: auto) =
|
||||
for i in countdown(x.low, x.high):
|
||||
echo i
|
||||
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ discard """
|
|||
proc test(x: proc (a, b: int): int) =
|
||||
echo x(5, 5)
|
||||
|
||||
test(proc (a, b): auto = a + b)
|
||||
test(proc (a, b: auto): auto = a + b)
|
||||
|
||||
test do (a, b) -> auto: a + b
|
||||
test do (a, b: auto) -> auto: a + b
|
||||
|
||||
proc foreach[T](s: seq[T], body: proc(x: T)) =
|
||||
for e in s:
|
||||
body(e)
|
||||
|
||||
foreach(@[1,2,3]) do (x):
|
||||
foreach(@[1,2,3]) do (x: auto):
|
||||
echo x
|
||||
|
||||
proc foo =
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ proc noReturn(x: () -> void) =
|
|||
proc doWithOneAndTwo(f: (int, int) -> int): int =
|
||||
f(1,2)
|
||||
|
||||
echo twoParams(proc (a, b): auto = a + b)
|
||||
echo twoParams(proc (a, b: auto): auto = a + b)
|
||||
echo twoParams((x, y) => x + y)
|
||||
|
||||
echo oneParam(x => x+5)
|
||||
|
|
|
|||
39
tests/misc/tupcomingfeatures.nim
Normal file
39
tests/misc/tupcomingfeatures.nim
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
discard """
|
||||
output: '''0 -2 0
|
||||
0 -2'''
|
||||
"""
|
||||
|
||||
{.this: self.}
|
||||
|
||||
type
|
||||
Foo {.partial.} = object
|
||||
a, b: int
|
||||
|
||||
type
|
||||
tupcomingfeatures.Foo = object
|
||||
x: int
|
||||
|
||||
proc yay(self: Foo) =
|
||||
echo a, " ", b, " ", x
|
||||
|
||||
proc footest[T](self: var Foo, a: T) =
|
||||
b = 1+a
|
||||
yay()
|
||||
|
||||
proc nongeneric(self: Foo) =
|
||||
echo a, " ", b
|
||||
|
||||
var ff: Foo
|
||||
footest(ff, -3)
|
||||
ff.nongeneric
|
||||
|
||||
{.experimental.}
|
||||
using
|
||||
c: Foo
|
||||
x, y: int
|
||||
|
||||
proc usesSig(c) =
|
||||
echo "yummy"
|
||||
|
||||
proc foobar(c, y) =
|
||||
echo "yay"
|
||||
|
|
@ -5,7 +5,7 @@ template someIt(a, pred: expr): expr =
|
|||
var it {.inject.} = 0
|
||||
pred
|
||||
|
||||
proc aProc(n) =
|
||||
proc aProc(n: auto) =
|
||||
n.someIt(echo(it))
|
||||
|
||||
aProc(89)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ discard """
|
|||
|
||||
import typetraits
|
||||
|
||||
proc plus(a, b): auto = a + b
|
||||
proc makePair(a, b): auto = (first: a, second: b)
|
||||
proc plus(a, b: auto): auto = a + b
|
||||
proc makePair(a, b: auto): auto = (first: a, second: b)
|
||||
|
||||
proc `+`(a, b: string): seq[string] = @[a, b]
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ static: assert p[0].type is string
|
|||
echo i.type.name
|
||||
echo s.type.name
|
||||
|
||||
proc inst(a): auto =
|
||||
proc inst(a: auto): auto =
|
||||
static: echo "instantiated for ", a.type.name
|
||||
result = a
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue