parent
acbe27b082
commit
0426a4d85a
2 changed files with 34 additions and 6 deletions
21
tests/effects/tfuncs_cannot_mutate_simple.nim
Normal file
21
tests/effects/tfuncs_cannot_mutate_simple.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
discard """
|
||||
errormsg: "'edit' can have side effects"
|
||||
nimout: '''an object reachable from 'x' is potentially mutated
|
||||
tfuncs_cannot_mutate_simple.nim(17, 4) the mutation is here'''
|
||||
line: 16
|
||||
"""
|
||||
|
||||
{.experimental: "strictFuncs".}
|
||||
|
||||
# bug #15508
|
||||
|
||||
type
|
||||
MyType = ref object
|
||||
data: string
|
||||
|
||||
func edit(x: MyType) =
|
||||
x.data = "hello"
|
||||
|
||||
let x = MyType()
|
||||
x.edit()
|
||||
echo x.data
|
||||
Loading…
Add table
Add a link
Reference in a new issue