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 contains a type error because the $0 in substitution[$0] is of type VarName, while substitution maps {{Var}}s to {{Var}}s. However, the compiler reports it as:
which does not make sense, given that there is an overload for BoolExpr.
While trying to minimize this example I've also hit another likely related issue. To reproduce this one replace the class X definition in the program above with this:
1. The signature of substitute here is (BoolExpr, Substitution) -> BoolExpr, but you're trying to add the returned value to an array of type [Expr]. To fix this, what you need is another method of type (BoolExpr, Substitution) -> Expr or change the type of the array to be [BoolExpr].
2. You also have another error on the same line: substitution[$0]. This is incorrect because the type of substitution is [Var: Var] (where Var = struct Var), where as you're trying to subscript it with $0 which is a VarName (a typealias for String), because Substitution is a typealias for (VarName) -> VarName.
Look, I agree this code is incorrect, and it has been indicated in the issue title as well... My point is that both error messages I'm getting are completely false and do not direct me to the real cause of failure.
The snippets I've pasted here are a minimal version of the code I was writing in a real application, and I kept minimizing them until those particular errors disappeared, so I might have introduced extra type errors in the process. Thanks for catching them, but I feel like this only highlights how bad the error message is, given how many realtype errors there are 🙂
Environment
Apple Swift version 5.1 (swiftlang-1100.0.257.2 clang-1100.0.31.3)
Additional Detail from JIRA
md5: ae43068899072811621c00229f5a7440
Issue Description:
Consider this piece of code:
It contains a type error because the
$0
insubstitution[$0]
is of typeVarName
, whilesubstitution
maps {{Var}}s to {{Var}}s. However, the compiler reports it as:which does not make sense, given that there is an overload for
BoolExpr
.While trying to minimize this example I've also hit another likely related issue. To reproduce this one replace the
class X
definition in the program above with this:This program suffers from the same type error as the original one, but the reported failure is now:
which is again obviously false given that
print(lookup[x])
type checks successfully.The text was updated successfully, but these errors were encountered: