mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
* kochdocs.nim: code cleanup * docgen: nicer indentation * parser.nim: code cleanup * fixes #10458 * make tests green again * make =destroy mixins * gc:destructors: produced C code is almost working * --gc:destructors simple program compiles (but leaks memory) * gc:destructors make examples compile in C++ mode * destructors: string implementation bugfixes * strs.nim: minor code cleanup * destructors: builtin seqs are beginning to work * remove debugging helpers
52 lines
769 B
Nim
52 lines
769 B
Nim
discard """
|
|
output: '''holla
|
|
true
|
|
defabc 4
|
|
0'''
|
|
"""
|
|
|
|
# Test top level semicolon works properly:
|
|
import os; echo "holla"
|
|
|
|
# Test the new predence rules
|
|
|
|
proc `\+` (x, y: int): int = result = x + y
|
|
proc `\*` (x, y: int): int = result = x * y
|
|
|
|
echo 5 \+ 1 \* 9 == 6*9
|
|
|
|
proc foo[S, T](x: S, y: T): T = x & y
|
|
|
|
proc bar[T](x: T): T = x
|
|
|
|
echo "def".foo[:string, string]("abc"), " ", 4.bar[:int]
|
|
|
|
# bug #9574
|
|
proc isFalse(a: int): bool = false
|
|
|
|
assert not isFalse(3)
|
|
|
|
# bug #9633
|
|
|
|
type
|
|
MyField = object
|
|
b: seq[string]
|
|
|
|
MyObject = object
|
|
f: MyField
|
|
|
|
proc getX(x: MyObject): lent MyField {.inline.} =
|
|
x.f
|
|
|
|
let a = MyObject()
|
|
echo a.getX.b.len
|
|
|
|
|
|
# bug #10458
|
|
template t(x: untyped): untyped = "x"
|
|
|
|
let
|
|
aaa = t 2 + 4
|
|
ccc = t (1, 1) + 6
|
|
ddd = t [0, 1, 2] + 5
|