mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
* 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
36 lines
574 B
Nim
36 lines
574 B
Nim
discard """
|
|
errormsg: "cannot mutate location select(x, z).data within a strict func"
|
|
line: 35
|
|
"""
|
|
|
|
{.experimental: "strictFuncs".}
|
|
|
|
type
|
|
Node = ref object
|
|
le, ri: Node
|
|
data: string
|
|
|
|
func insert(x: var seq[Node]; yyy: Node) =
|
|
let L = x.len
|
|
x.setLen L + 1
|
|
x[L] = yyy
|
|
|
|
func len(n: Node): int =
|
|
var it = n
|
|
while it != nil:
|
|
inc result
|
|
it = it.ri
|
|
|
|
func doNotDistract(n: Node) =
|
|
var m = Node(data: "abc")
|
|
|
|
func select(a, b: Node): Node = b
|
|
|
|
func mutate(n: Node) =
|
|
var it = n
|
|
let x = it
|
|
let y = x
|
|
let z = y
|
|
|
|
select(x, z).data = "tricky"
|