Thank you, that works great! Simply being careful to assign the output of the
staticExec calls to const variables did the trick. As a nice side effect it
also fixes the issue I had with the more complex version of my function.
I have a final question which is: shouldn't the compiler be able to see that
the output of get_version() is being assigned to a const variable, even if I
did not use the intermediate const variable? That is, shouldn't these two
functions work the same?:
# This procedure compiles fine
proc get_version_compiles_ok(): string =
const res = staticExec("hg log -r . --template
\"{latesttag}+{latesttagdistance} ({node}|short})\"")
result = res
const version_info_ok = get_version_compiles_ok()
# This procedure does not compile
proc get_version_compile_failure(): string =
result = staticExec("hg log -r . --template
\"{latesttag}+{latesttagdistance} ({node}|short})\"")
const version_info_fail = get_version_compile_failure()