Closed tbekas closed 8 months ago
Thanks @tbekas, the reproduction code is really helpful. I was able to make it a bit smaller still:
proc foo(_: type): ?!int =
if error =? success(1).errorOption:
discard
proc bar = # defined, but not used
without x =? bool.foo(), error:
return
discard bool.foo() # same type parameter 'bool' as used in bar()
It's an interesting problem, basically the hack that I put in binderror.nim
to check whether we need to capture an error doesn't work here. The generic proc foo
is first instantiated in the compiler when compiling bar
, and here we do need to capture the error. But the same instantiation of the generic proc foo
is then used in a context where we don't need to capture the error.
Thanks for checking, confirming it and making it yet smaller :)
Tested on nim
1.6.14
Happens within procs that have a type param and that are called by one of imports within
without
macromain.nim
somefn.nim
otherfn.nim
If we run
nim c -r main.nim
we get: