Files
Nim/tests/effects/tfuncs_cannot_mutate2.nim
Andreas Rumpf 3812d91390 alternative, much simpler algorithm for strict func checking (#21066)
* alternative, much simpler algorithm for strict func checking

* forgot to git add new compiler module

* new spec is incredibly simple to describe

* fixes bigints regression

* typos

* closes #16305; closes #17387; closes #20863
2022-12-11 16:58:50 +01:00

25 lines
392 B
Nim

discard """
errormsg: "cannot mutate location x[0].a within a strict func"
line: 12
"""
{.experimental: "strictFuncs".}
func copy[T](x: var openArray[T]; y: openArray[T]) =
for i in 0..high(x):
x[i] = y[i]
x[0].a = nil
type
R = ref object
a, b: R
data: string
proc main =
var a, b: array[3, R]
b = [R(data: "a"), R(data: "b"), R(data: "c")]
copy a, b
main()