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
While the syntax error is on return $0, the compiler gives an error on the return nil statement: 'nil' is not compatible with closure result type 'String'
Which is completely garbage since we use compactMap.
It looks like a syntax error inside a closure breaks compiler inference, producing invalid error messages.
If we comment out the return nil, the the compiler is finally able to give a proper error message: Cannot convert value of type 'Int' to closure result type 'String'
Description
If a syntax error occurs inside a closure, the compiler may fail to report the error.
As an example:
While the syntax error is on
return $0
, the compiler gives an error on thereturn nil
statement:'nil' is not compatible with closure result type 'String'
Which is completely garbage since we use
compactMap
.It looks like a syntax error inside a closure breaks compiler inference, producing invalid error messages.
If we comment out the
return nil
, the the compiler is finally able to give a proper error message:Cannot convert value of type 'Int' to closure result type 'String'
Files
main.swift.zip
The text was updated successfully, but these errors were encountered: