The compiler can't distinguish proc from field when both identifiers have the same name. I tried compiling the provided example with a func and method instead of proc. Still fails.
type Status = object
response: string
proc response(s: var Status, r: string) =
s.response = r
var s: Status
s.response("stoof")
~ $ nim cc .\main.nim
Hint: used config file 'C:\Program Files\Nim\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: main [Processing]
Error: in expression 's.response("stoof")': identifier expected, but found 's.response'
~ $ nim cc .\main.nim
Hint: used config file 'C:\Program Files\Nim\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: main [Processing]
CC: stdlib_system.nim
CC: main.nim
Hint: [Link]
Hint: 14208 LOC; 0.833 sec; 16.133MiB peakmem; Debug build; proj: ~\Downloads\main.nim; out: ~\Downloads\main.exe [SuccessX]
~ $ nim -v
Nim Compiler Version 1.2.6 [Windows: amd64]
Compiled at 2020-07-29
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: bf320ed172f74f60fd274338e82bdc9ce3520dd9
active boot switches: -d:release
Field accesses take priority over scope expansions. Not sure if there is a bug here.
If not considered as a bug, would you consider it as a feature then?
Most helpful comment
Field accesses take priority over scope expansions. Not sure if there is a bug here.