blob: 85a7cf97df653d862cf6bfc25cd7d99127c08a97 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
discard """
cmd: '''nim check --hints:off $file'''
action: reject
nimout: '''
t19986.nim(19, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
t19986.nim(28, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
t19986.nim(37, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
'''
"""
{.experimental: "views".}
type
Object = object
id: int
proc foo() =
let a = Object(id: 3)
var foo: var Object = a
foo.id = 777
echo a
foo()
proc bar() =
let a = "123"
var foo: var string = a
foo[0] = '7'
echo a
bar()
proc main() =
let a = 3
var foo: var int = a
foo = 777
echo a
main()
|