will / crystal-pg

a postgres driver for crystal
BSD 3-Clause "New" or "Revised" License
462 stars 77 forks source link

Silence `_oid` argument warning #262

Closed jgaskins closed 1 year ago

jgaskins commented 1 year ago

This warning appears on the latest Crystal versions:

In src/pg/decoder.cr:86:32

 86 | def decode(io, bytesize, _oid)
                               ^---
Warning: positional parameter '_oid' corresponds to parameter 'oid' of the overridden method PG::Decoders::Decoder#decode(io, bytesize, oid), which has a different name and may affect named argument passing

If the argument is expoosed outside the method as the name the Crystal compiler expects, this warning goes away. I kept the underscore-prefixed name as the internal variable name so it would remain clear it's not used.

jgaskins commented 1 year ago

Looks like this was unneeded. I don't know what happened to my local repo. 🙃

will commented 1 year ago

@jgaskins Thanks for opening this though, I had never seen giving arguments two names like that before though, that's neat :)

jgaskins commented 1 year ago

It really is. I like the expressiveness it adds to method signatures like def move(from source, to destination) or macro render(template, to io).