Re: Fields with the same name not causing a warning?

2018-11-16 Thread Dennis via Digitalmars-d-learn
On Friday, 16 November 2018 at 20:13:42 UTC, Vinay Sajip wrote: More complicated for the compiler writers, or users of mixins/generics? For users of generics. It's hard to come up with an actual example because I don't know why one would ever use this, but in this concocted scenario: ```

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Norm via Digitalmars-d-learn
On Friday, 16 November 2018 at 15:59:14 UTC, Vinay Sajip wrote: This code should IMO give at least a warning, but it doesn't: abstract class A { int kind; } [...] This is not unique to D you can do the same in Java or C++. bye, Norm

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Vinay Sajip via Digitalmars-d-learn
On Friday, 16 November 2018 at 19:12:42 UTC, Dennis wrote: If something is definitively wrong, then it should be an error. If it's not definitively wrong, then the compiler shouldn't say anything about it, and it should be left up to a linter tool of some kind like dcd."

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Dennis via Digitalmars-d-learn
On Friday, 16 November 2018 at 18:37:00 UTC, Vinay Sajip wrote: Design flaws in what? Design flaws in the language. Quoting Jonathan M Davis: "Honestly, in general, warnings are a terrible idea. Anything that's a warning in your code has to be fixed, because it's bad practice to leave

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Vinay Sajip via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:35:13 UTC, Basile B. wrote: D is not a compiler that warns much. You can still open an issue asking for this (and the warning must be easy to add at first glance), but the policy applied to warnings is "compilers warnings are a sign of design flaws so instead

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Basile B. via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:28:15 UTC, Vinay Sajip wrote: On Friday, 16 November 2018 at 17:08:00 UTC, Basile B. wrote: I agree that this is almost a case of shadowing but i don't know the exact rationale for allowing this. I'm not saying it shouldn't be allowed - just that the

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Vinay Sajip via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:08:00 UTC, Basile B. wrote: I agree that this is almost a case of shadowing but i don't know the exact rationale for allowing this. I'm not saying it shouldn't be allowed - just that the compiler could warn you about what might very well be a mistake (as it

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Basile B. via Digitalmars-d-learn
On Friday, 16 November 2018 at 15:59:14 UTC, Vinay Sajip wrote: This code should IMO give at least a warning, but it doesn't: abstract class A { int kind; } class B : A { int kind; this(int k) { kind = k; } } In my actual code, the declaration of field "kind" in B was

Fields with the same name not causing a warning?

2018-11-16 Thread Vinay Sajip via Digitalmars-d-learn
This code should IMO give at least a warning, but it doesn't: abstract class A { int kind; } class B : A { int kind; this(int k) { kind = k; } } In my actual code, the declaration of field "kind" in B was left in accidentally. Surprisingly, however, no warning was