Nim/tests/tconstr1.nim
2008-06-22 16:14:11 +02:00

29 lines
719 B
Nim
Executable file

# Test array, record constructors
import
io
type
TComplexRecord = record
s: string
x, y: int
z: float
chars: set[Char]
proc testSem =
var
things: array [0..1, TComplexRecord] = [
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45, z: 0.0),
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45, z: 1.0)
]
write(stdout, things[0].x)
const
things: array [0..] of TComplexRecord = [
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45, z: 0.0),
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45) #ERROR
]
otherThings = [ # the same
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45, z: 0.0),
(chars: {'a', 'b', 'c'}, s: "hi", x: 69, y: 45)
]