Test
proc foo(_, _: int) = discard
Expected
Compiles with no issue. It works for one underscore, though I'm not sure this is even a feature.
Got
Test.nim(1, 13) Error: attempt to redefine: '_'
>nim -v
Nim Compiler Version 1.1.1 [Linux: i386]
Compiled at 2020-02-19
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 8c22518d673cf792fa064d2d561d1c6f03b823bb
active boot switches: -d:release
Maybe this works as expected?
error: redefinition of parameter '_'
N_LIB_PRIVATE N_NIMCALL(void, foo__BOpZ9bkFh9cyFk2iF9aui4mXw)(NI _, NI windx, NI _);
If the _ isn't mangled, it is natural to cause this result.
Maybe this needs to be documented instead of being fixed?
for consistency with (EDIT) https://github.com/nim-lang/Nim/issues/15972, IMO proc foo(_, _: int) = discard should be allowed.
Would avoid having to use dummy names eg in:
proc bar(a: int, fun: proc(_: int, _: float)) = discard
@timotheecour
Wrong RFC link.
If mangling underscore names is more consistent, I will try that.
@xflywind thx, fixed link
Because JS backend mangles function parameters, it does work in JS backend and VM.
proc foo(_, _: int) = echo "123"
foo(1, 2)
function foo_385875969(__385875971, __385875972) {
rawEcho(makeNimstrLit("123"));
}
foo_385875969(1, 2);