Basically foo.bar tries to call the proc which returns an immutable number,
here is a reworked example that avoids name conflicts:
type
Foo* = object
internal_bar: int
proc `bar`*(f: Foo): int {.inline.} =
## Getter for immutable Foo
f.internal_bar
proc `bar`*(f: var Foo): var int {.inline.} =
## Getter for mutable Foo
f.internal_bar
proc `bar=`*(f: var Foo, val: int) {.inline.} =
## Setter
f.bar = val
proc `+=`*(f: var Foo, val: int) {.inline.} =
# Operand
f.bar += val
Run
Note that getters and setters are very unidiomatic as @Stefan_Salewski said,
just export the internal fields unless you have specific validation routines,
pre/post-processing you need to do at each field accesses.