-
Notifications
You must be signed in to change notification settings - Fork 568
Fix VTAs wildcard inferred warning #4492
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
Conversation
Don't all the functions that use |
Could you give an example of what you mean? Meaning, what would this look like in syntax?
|
This is a highly contrived example, but I imagine something like this: class Foo a b c | a -> b c where
fooMember :: a -> b
f :: forall @a. Array a -> Array (Array a)
f as = [as]
x :: forall c. Array (Foo Int Boolean c => Int -> Boolean)
x = [fooMember]
y :: forall c. Array (Array (Foo Int Boolean c => Int -> Boolean))
y = f @(Foo Int Boolean _ => _) x -- neither wildcard should warn IMO |
Using your contrived example, no wildcard is emitted. |
Tests that no warnings are issued need to be in |
Ah.... No, you're right. I see the issue now. |
I can confirm that |
Description of the change
Fixes #4488.
The problem initially arises when we convert the
ExprVisibleApp
(CST value) intoVisibleTypeApp
(AST value). UsingconvertType
, whenever we come across a wildcard, we always convert the resulting value into anUnnamedWildcard
.Later, right before we typecheck a module's declarations, we update all
UnnamedWildcard
toIgnoreWildcard
if they appear in a specific context viaignoreWildcardsUnderCompleteTypeSignatures
. Because Visible Type Applications are a separate concept, they aren't converted here. Presumably, while typechecking, the compiler emits a warning for eachUnnamedWildcard
found, which produces the issue.Thus, there are two ways to resolve this:
convertType
to take another arg indicating whether it was called while converting anExprVisibleApp
into aVisibleTypeApp
. If it was, then convert any wildcards intoIgnoreWildcard
in the first place. This solves the root of the problem but any other usages ofconvertType
don't have this special rule in place.ignoreWildcards*
function to also account forVisibleTypeApp
. This is a smaller change but comes at the cost of another traversal through the AST.AFAICT,
convertType
is only used in two other places, both of which I think aren't affected by this change:Checklist: