Files
Nim/tests/constr/tconstr1.nim
Adam Strzelecki e80465dacf tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:04:32 +02:00

31 lines
731 B
Nim

discard """
file: "tconstr1.nim"
line: 25
errormsg: "type mismatch"
"""
# Test array, record constructors
type
TComplexRecord = tuple[
s: string,
x, y: int,
z: float,
chars: set[char]]
proc testSem =
var
things: array [0..1, TComplexRecord] = [
(s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})]
write(stdout, things[0].x)
const
things: array [0..1, TComplexRecord] = [
(s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0)] #ERROR
otherThings = [ # the same
(s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})]