I've been trying to silence one million different hints coming from system (std) libraries, but I still cannot manage to see how...
Here's an example of what I mean (the list is practically endless, this is just a sample - and the problem is that amidst all these, I cannot spot the warnings and hints that are related to my code):
../../.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(203, 31) Warning: 'handlerIter' is not GC-safe as it calls 'currentPath' [GcUnsafe2]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2668, 17) Hint: passing 'a' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/parseopt.nim(354, 37) Hint: passing 'p.cmds[p.idx + 1]' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/parseopt.nim(365, 33) Hint: passing 'p.cmds[p.idx]' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2163, 27) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2171, 23) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2163, 27) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2171, 23) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2163, 27) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2171, 23) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2163, 27) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/os.nim(2171, 23) Hint: passing 'y' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/httpcore.nim(151, 23) Hint: passing 'headers.table[toCaseInsensitive(headers, key)]' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/httpclient.nim(1074, 46) Hint: passing 'resp.status' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/collections/tables.nim(662, 23) Hint: passing 'tbl.data[h].key' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/collections/tables.nim(662, 38) Hint: passing 'tbl.data[h].val' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/osproc.nim(960, 26) Hint: passing 'data.sysCommand' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/httpclient.nim(1165, 46) Hint: passing 'resp.status' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/asyncdispatch.nim(1286, 39) Hint: passing 'adata.readList' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
../../.choosenim/toolchains/nim-#devel/lib/pure/httpcore.nim(217, 14) Hint: passing 'current' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it [Performance]
Here's how I'm trying to solve it:
{.push hints:off.}
import (system libraries)
{.pop.}
However, this seems to make no difference whatsoever and I keep getting the exact same hints and warnings.
Nim Compiler Version 1.5.1 [MacOSX: amd64]
Compiled at 2020-10-16
Copyright (c) 2006-2020 by Andreas Rumpf
And I'm compiling with:
--warning[UnusedImport]:off" --colors:off -d:PYTHONIC -d:release -d:danger --panics:off --gc:arc --checks:off --overflowChecks:on -d:ssl
Any ideas?
My top level advice was going to be pass --hints:off on the command line, and
{.hints:on.}
#...usercode you'd like to get [Performance] hints for
{.pop.}
but that doesn't actually work. let me see if i can explain
{.push hints:off.}
import parseopt
{.pop.}
#this only disables hints for any code compiled at module import
#i.e. in general this will do nothing, as code only gets compiled when it's used
{.push hints:off.}
var p = initOptParser()
{.pop.}
#if hints are on when initOptParser is instantiated, that causes
# parseCmdLine from os.nim to be compiled, which generates the
# [Performance] hint you see. so to disable the os.nim hints,
# hints have to be off at this point in user code
{.push hints:off.}
p.next()
{.pop.}
#this line causes "next" from parseopt.nim to be compiled,
# so again, if hints are on at this point, the [Performance]
# hints from parseopt.nim will be shown
It's worth pointing out that this has never worked, but has become much more noticeable as gc:arc has made a lot of stdlib code raise [Performance] or [ObservableStores] hints/warnings
a way to disable hints per-import would clearly be a useful feature, and/or refactoring the stdlib to prevent the warnings from occurring, but I'm not sure what the workaround is until then.
so, i'm not sure what to tell you, sorry.
@ElAfalw please always show a minimal reproducible example to help others.
I've encountered similar issues.
(from memory, please correct if wrong) for better of for worse, notes (warnings and hints) have a notion of:
notes (apart from --hints:off IIRC) typically control only main package notes.
If you want to improve situation, you can start looking at this code snippet in nim repo:
graph.config.notes =
if s.getnimblePkgId == graph.config.mainPackageId or isDefined(graph.config, "booting"): graph.config.mainPackageNotes
else: graph.config.foreignPackageNotes
the question is, what should be desired semantics, and should there be options to operate on "all notes" instead of just main package notes