Type declarations in function generics cause issues when names overlap · Issue #332 · luau-lang/luau · GitHub
More Web Proxy on the site http://driver.im/
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
When explicitly declaring function generics, the generic types leak outside of the function and can cause issues if other generic types for other functions are of the same name
Not 100% sure if this is a bug, but I don't believe generic types inside functions should leak and affect the behavior of generics of another even when both have the same name
Fairly sure this started happening since commit 2f989fc049772f36de1a4281834c375858507bda
(I rarely post issues so if I've done something incorrectly, please let me know)
--!nonstrict--consider the following code under --!nonstrictlocalutil= {}
functionutil.matchDict<K, V>(lambda: (key: K, value: V) ->boolean?, dict: {[K]: V}): (K?, V?)
fork, vinpairs(dict) doiflambda(k, v) ==truethenreturnk, vendendreturnnil, nilendfunctionutil.matchDictAll<K, V>(lambda: (key: K, value: V) ->boolean?, dict: {[K]: V}): {[K]: V}
localmatched= {}
fork, vinpairs(dict) do--this will throw a "Type {[K]: V} could not be converted into {[any]: any}" on the dictiflambda(k, v) ==truethenmatched[k] =vendendreturnmatchedend
--!nonstrictlocalutil= {}
functionutil.matchDict<K, V>(lambda: (key: K, value: V) ->boolean?, dict: {[K]: V}): (K?, V?)
fork, vinpairs(dict) doiflambda(k, v) ==truethenreturnk, vendendreturnnil, nilend--the generic type names are changed and no longer overlap with the previous functionfunctionutil.matchDictAll<X, Y>(lambda: (key: X, value: Y) ->boolean?, dict: {[X]: Y}): {[X]: Y}
localmatched= {}
fork, vinpairs(dict) do--the type error no longer occursiflambda(k, v) ==truethenmatched[k] =vendendreturnmatchedend
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
When explicitly declaring function generics, the generic types leak outside of the function and can cause issues if other generic types for other functions are of the same name
Not 100% sure if this is a bug, but I don't believe generic types inside functions should leak and affect the behavior of generics of another even when both have the same name
Fairly sure this started happening since commit
2f989fc049772f36de1a4281834c375858507bda
(I rarely post issues so if I've done something incorrectly, please let me know)
The text was updated successfully, but these errors were encountered: