-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid generic type deduction in mapIt
#23418
Comments
Notably, if |
Looks like a variation of #22479 |
ah, right but without destructor this time..
this applies though - also in the real bug of which this is a reproduction |
fwiw, we've seen this bug in many different places though we never teased out a repro as simple as here - the showstopper label on 22479 feels appropritate |
workaround: import sequtils
type F[T, E] = object
dummy: array[0, E]
proc start(v: int): F[void, (ValueError,)] = discard
proc stop(v: int): F[void, tuple[]] = discard
var a = mapIt([1, 2, 3], start(it))
assert $type(a) == "seq[F[system.void, (ValueError,)]]", $type(a)
var b = mapIt([1, 2, 3], stop(it))
assert $type(b) == "seq[F[system.void, tuple[]]]", $type(b) |
Reduced example: template mapIt*(x: untyped): untyped =
type OutType = typeof(x, typeOfProc)
newSeq[OutType](5)
type F[T, E] = object
proc start(v: int): F[void, (ValueError,)] = discard
proc stop(v: int): F[void, tuple[]] = discard
var a = mapIt(start(9))
assert $type(a) == "seq[F[system.void, (ValueError,)]]", $type(a)
var b = mapIt(stop(9))
assert $type(b) == "seq[F[system.void, tuple[]]]", $type(b) |
Description
The expectation is that the
b
type is derived fromstop
, yet thestart
type gets reused..Nim Version
1.6, devel
Current Output
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: