I added this --hint:Performance:on to the compiler and this message is displayed :
Hint: passing 'e.msg' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
try:
let opts = mycommand()
except ValueError as e:
raise newException(ValueError, e.msg)
I don't understand, what should I do in my code to eliminate this warning? You can try:
raise newException(ValueError, move e.msg)
But I doubt it compiles as e is readonly. Or maybe not, I don't know. :-)
e is a ref so it's probably not readonly (unfortunately) so it probably can be moved from - enforceMove can probably tell - we should really rename move to moveIfPossibleAndNotBuggy and enforceMove to move ...
Since this is the last use of e, msg could be moved from it automatically as well - this is a similar issue as https://github.com/nim-lang/Nim/issues/23395.
Thank you all for your comments.
@Araq, with move the hint has disappeared.