-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Nim Version
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-09-25
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 9f74712ec6ec346f8f1366c10f752d0a9aa85a70
active boot switches: -d:release
Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-04-22
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release
Description
This should not compile:
proc print(x: int) =
echo x
proc inc(x: var int) =
x += 1
type MyObj = object
data: pointer
size: int
template view(obj: MyObj): int =
let data = obj.data
cast[ptr int](data)[]
let x = @[1, 2, 3]
let y = MyObj(data: addr x[0], size: x.len)
print(y.view)
inc(y.view)
print(y.view)
Current Output
1
2
Expected Output
Known Workarounds
No response
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels