Replies: 6 comments 5 replies
-
This is an example of a cascading error. The first error is the lack of 'partial'. The language requires that if there are two source types with the same name and same arity in a namespace. At that point though, the program is in error and we the compiler can decide whatever it wants in terms of how to interpret things and how to proceed. Here, we have chosen to interpret this as the user accidentally forgetting 'partial', and we take the interpretation that the types are actually partially and are merged together. This of course can lead to further errors (as can not merging them). As strategies go, this serves us better than the opposite approach and leads to less false errors and more true ones. The overall strategy is not a bug. That said, you could argue that errors/warnings related to 'partial correctness' (such as the message about the type parameter names) should not be issued if not all parts have the |
Beta Was this translation helpful? Give feedback.
-
The following elicits only CS0101 public class A
{
}
public class A
{
} as does public class A<T>
{
}
public class A<T>
{
} This seems inconsistent with your explanation, why assume a |
Beta Was this translation helpful? Give feedback.
-
This is confusing, if we assume these are two declarations each missing the public class A
{
}
public class A
{
} If the analysis is that the user has left out a The error reported is If the latter is what the analysis thinks the problem is, why not tell the user that? that seems like a better diagnostic message and could be consistently reported in each of the three cases. It's simply the diagnostic that I think should be changed, not the analysis, anyway that's how it looks to me, do with it what you wish. |
Beta Was this translation helpful? Give feedback.
-
The issue is that there's a duplicate. So we report that Our error recovery strategy is then to guys at what you meant and continue from there.
As stated a couple of times already. We would accept reasonably sized PRs that improve the clarity of error recovery and any effected diagnostics past that point.
If you find this situation confusing, we would welcome your assistance in improving it. As mentioned, I'm happy to work with you on gitter or discord to make a PR to improve the situation here. All I was trying to do above was explain what error recovery was doing and why it led to the messages you're seeing. |
Beta Was this translation helpful? Give feedback.
-
While we're here is there a reason why this is not allowed? public class Generic<T> where T : class
{
}
public class Generic<T> where T : struct
{
} It seems these are distinguishable and there's no prospect of ambiguity, so I am curious, in each of these cases we know more than just the lexical identifier of each generic arg, there is further metadata available to distinguish between them, seems the detection of duplicate generic signatures is disregarding that metadata. |
Beta Was this translation helpful? Give feedback.
-
Understood and thank you, I will see if I can suggest something practical here, thanks for your comments. |
Beta Was this translation helpful? Give feedback.
-
The following - illegal - code generates CS0264:
This seems wrong to me since clearly there is no use of
partial
here.Beta Was this translation helpful? Give feedback.
All reactions