mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* Breaking parser changes, implement https://github.com/nim-lang/RFCs/issues/442 Types are separated from expressions and better reflected in the grammar. * add test * more accurate grammar * fix keyword typedescs * accept expressions in proc argument lists * CI "fixes" * fixes * allow full ref expressions again, adapt old tests * cleanup, fix some tests * improve grammar, try and revert semtypes change * restrict sigil binding to identOrLiteral * fix, should have caught this immediately * add changelog entry, fix double not nil bug * correct grammar * change section * fix * real fix hopefully * fix test * support LL(1) for tuples * make grammar.txt too
48 lines
696 B
Nim
48 lines
696 B
Nim
discard """
|
|
output: '''140
|
|
5-120-120
|
|
359
|
|
77
|
|
-4
|
|
-1
|
|
-1'''
|
|
"""
|
|
#import math
|
|
import sequtils
|
|
|
|
proc optarg(x:int, y:int = 0):int = x + 3 * y
|
|
proc singlearg(x:int):int = 20*x
|
|
echo optarg 1, singlearg 2
|
|
|
|
|
|
proc foo(x: int): int = x-1
|
|
proc foo(x, y: int): int = x-y
|
|
|
|
let x = optarg foo 7.foo
|
|
let y = singlearg foo(1, foo 8)
|
|
let z = singlearg 1.foo foo 8
|
|
|
|
echo x, y, z
|
|
|
|
let a = [2,4,8].map do (d:int) -> int: d + 1
|
|
echo a[0], a[1], a[2]
|
|
|
|
echo(foo 8, foo 8)
|
|
|
|
# bug #7582
|
|
proc f(x: int): int = x
|
|
|
|
echo f -4
|
|
|
|
echo int -1 # doesn't compile
|
|
echo int `-` 1 # compiles
|
|
|
|
var num = 1
|
|
num += int 2
|
|
doAssert num == 3
|
|
|
|
import options
|
|
var opt = some some none int
|
|
opt = some some none int
|
|
opt = some none Option[int]
|