summary refs log tree commit diff stats
path: root/tests/vm/twrongconst.nim
blob: a329cb578709f7a7429426731e06e2a9afd3be90 (plain) (blame)
1
2
3
4
5
6
7
8
9
discard """
  errormsg: "cannot evaluate at compile time: x"
  line: 7
"""

var x: array[100, char]
template foo : char = x[42]

const myConst = foo
an> object elt: float template defineOpAssign(T, op: untyped) = proc `op`*(v: var T, w: T) {.inline.} = for i in 0..1: `op`(v.elt, w.elt) const ATTEMPT = 0 when ATTEMPT == 0: # FAILS: defining `/=` with template calling template # ERROR about sem.nim line 144 template defineOpAssigns(T: untyped) = mixin `/=` defineOpAssign(T, `/=`) defineOpAssigns(Foo) # bug #1543 import sequtils (var i = @[""];i).applyIt(it) # now works: echo "##", i[0], "##"