You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible this could be shrunken a little, but it's pretty minimal.
typeOat*[K, Q] =concept t
eq(t, K, K) isboolkey(t, int) is K
Valued*[V] =concept t
val(var t, int, V)
val(t, int) is V
VOat*[K,Q,V] =concept t
t isValued[V]
t isOat[K,Q]
procgetOrDefault*[K,Q,V](t: VOat[K,Q,V], q: Q, def=default(V)): V =discardtypeCount=object
cnt: int
key: stringCounts=object
dat: seq[Count]
proceq(t: Counts, a: string, b: string): bool= a == b
prockey(c: Counts, i: int): string= c.dat[i].key
procval(c: varCounts, i: int, v: int) = c.dat[i].cnt = v
procval(c: Counts, i: int): int= c.dat[i].cnt
procfoo() =var h: Countswhendefined bug: # infinite loops compiler & nimsuggestlet x =getOrDefault(h, "hi")
else:
let x =getOrDefault[string, string, int](h, "hi") # works
Nim Version
Compiling with nim c -d:bug makes all versions of Nim I have around infinite loop. This is at least 0.20.2, 1.2, 1.4, 1.6, 2.0, and current devel head.
Current Output
None. Infinite loop with memory exhaustion.
Expected Output
Either correct compilation with the instantiated inferred or an instantiation error.
Known Workarounds
Always provide the generic parameter list with instance values. It is pretty bothersome need nimsuggest to infinite recurse as a "signal" that one needs to do this, however.
Additional Information
EDIT: The def=default(V) might look troubling to some, but dropping that defaulted parameter entirely seems to not change anything, but I'd like for that to work as well and so kept it in the code example in case this becomes a test case of some kind.
The text was updated successfully, but these errors were encountered:
This is an infinite cycle between a tyInferred type matching the given type against its generic parameter, when the generic parameter is somehow bound to a typedesc of the tyInferred type itself, which is then matched again.
Description
It's possible this could be shrunken a little, but it's pretty minimal.
Nim Version
Compiling with
nim c -d:bug
makes all versions of Nim I have around infinite loop. This is at least 0.20.2, 1.2, 1.4, 1.6, 2.0, and current devel head.Current Output
Expected Output
Known Workarounds
Always provide the generic parameter list with instance values. It is pretty bothersome need
nimsuggest
to infinite recurse as a "signal" that one needs to do this, however.Additional Information
EDIT: The
def=default(V)
might look troubling to some, but dropping that defaulted parameter entirely seems to not change anything, but I'd like for that to work as well and so kept it in the code example in case this becomes a test case of some kind.The text was updated successfully, but these errors were encountered: