Basically, I'm doing something simple:
let (a,b) = getATuple(sth)
Then I'm using just b and the compiler complains that:
Hint: 'a`gensym452' is declared but not used [XDeclaredButNotUsed]
Which sounds fine.
Then I replace the parameter to be ignored by "_", but the result is the same:
Hint: '_`gensym1480' is declared but not used [XDeclaredButNotUsed]
And it's not just the hint. Looking at my cache folder, the code is generated just fine, as if the symbol was used.
What can I do? Is there any way to ignore it?
(Or, can you point me to the location in the compiler sources where this is handled?)
I wager you're using a template, those gensym the identifiers created inside them, so the way to stop that is using {.inject.} as the following.
template test =
let (a, _{.inject.}) = (100, 200)
test()
As far as I can tell from the gensyms, you're trying to do that in a template. Try adding a {.used.} pragma to your variable, like so:
let (a {.used.}, b) = getATuple(sth)
Thanks a lot for the suggestions!
Yes, it works beautifully!
And yep, I have been using it in a template - as @Araq had pointed out, I have tons of them...
Worth noting that used will cause issues if you have anymore than one _ in the template as the compiler will assume they're all the same.
gensymmed
Both you and ElegantBeef uses this term in a forum where a lot of newbie are in. Is it possible to sound less like a CS professor here? :-)
I'm also quite sure not everyone knows "to maintain scope hygiene" is or means, or why one personally needs to care about it and this isn't something the compilers does automatically.