digitalmars.D - Error or a new behaviour with 2.071.0
- Daniel Kozak (14/14) Apr 08 2016 From https://dlang.org/spec/attribute.html#ProtectionAttribute
- Dicebot (3/18) Apr 08 2016 The spec needs to be changed here (it was describing behaviour
- Vladimir Panteleev (3/26) Apr 08 2016 Yep. The previous behavior was bad because adding private symbols
- Daniel Kozak (8/23) Apr 08 2016 Btw:
- Steven Schveighoffer (10/37) Apr 08 2016 Someone just filed this morning:
- ZombineDev (4/30) Apr 08 2016 Even so, you shouldn't be able to make a local alias to private
- Steven Schveighoffer (5/26) Apr 12 2016 Sure, but the overloading behavior is expected is all I was saying. If
- ZombineDev (3/17) Apr 12 2016 Ah ok, I see where you're coming from.
From https://dlang.org/spec/attribute.html#ProtectionAttribute Protection does not participate in name lookup. In particular, if two symbols with the same name are in scope, and that name is used unqualified then the lookup will be ambiguous, even if one of the symbols is inaccessible due to protection. For example: module A; private class Foo {} module B; public class Foo {} import A; import B; Foo f1; // error, could be either A.Foo or B.Foo B.Foo f2; // ok But Foo f1; // works ok now with 2.071.0
Apr 08 2016
On Friday, 8 April 2016 at 13:28:15 UTC, Daniel Kozak wrote:From https://dlang.org/spec/attribute.html#ProtectionAttribute Protection does not participate in name lookup. In particular, if two symbols with the same name are in scope, and that name is used unqualified then the lookup will be ambiguous, even if one of the symbols is inaccessible due to protection. For example: module A; private class Foo {} module B; public class Foo {} import A; import B; Foo f1; // error, could be either A.Foo or B.Foo B.Foo f2; // ok But Foo f1; // works ok now with 2.071.0The spec needs to be changed here (it was describing behaviour that was a long-standing bug).
Apr 08 2016
On Friday, 8 April 2016 at 13:31:38 UTC, Dicebot wrote:On Friday, 8 April 2016 at 13:28:15 UTC, Daniel Kozak wrote:Yep. The previous behavior was bad because adding private symbols to a module should not break programs that import that module.From https://dlang.org/spec/attribute.html#ProtectionAttribute Protection does not participate in name lookup. In particular, if two symbols with the same name are in scope, and that name is used unqualified then the lookup will be ambiguous, even if one of the symbols is inaccessible due to protection. For example: module A; private class Foo {} module B; public class Foo {} import A; import B; Foo f1; // error, could be either A.Foo or B.Foo B.Foo f2; // ok But Foo f1; // works ok now with 2.071.0The spec needs to be changed here (it was describing behaviour that was a long-standing bug).
Apr 08 2016
On Friday, 8 April 2016 at 13:28:15 UTC, Daniel Kozak wrote:From https://dlang.org/spec/attribute.html#ProtectionAttribute Protection does not participate in name lookup. In particular, if two symbols with the same name are in scope, and that name is used unqualified then the lookup will be ambiguous, even if one of the symbols is inaccessible due to protection. For example: module A; private class Foo {} module B; public class Foo {} import A; import B; Foo f1; // error, could be either A.Foo or B.Foo B.Foo f2; // ok But Foo f1; // works ok now with 2.071.0Btw: import a : Foo; Foo f1; // works OK even if Foo is private Or even worse import a : Foo; import b; Foo f1; // works OK use a.Foo
Apr 08 2016
On 4/8/16 9:31 AM, Daniel Kozak wrote:On Friday, 8 April 2016 at 13:28:15 UTC, Daniel Kozak wrote:Someone just filed this morning: https://issues.dlang.org/show_bug.cgi?id=15896From https://dlang.org/spec/attribute.html#ProtectionAttribute Protection does not participate in name lookup. In particular, if two symbols with the same name are in scope, and that name is used unqualified then the lookup will be ambiguous, even if one of the symbols is inaccessible due to protection. For example: module A; private class Foo {} module B; public class Foo {} import A; import B; Foo f1; // error, could be either A.Foo or B.Foo B.Foo f2; // ok But Foo f1; // works ok now with 2.071.0Btw: import a : Foo; Foo f1; // works OK even if Foo is privateOr even worse import a : Foo; import b; Foo f1; // works OK use a.FooNote, import rules here say a.Foo is now a LOCAL symbol. It's like you did: import a; alias Foo = a.Foo; This trumps any other imports. This is a long-standing rule that was not implemented properly in previous versions. You can get the old behavior back I think by doing -transition=import for dmd. -Steve
Apr 08 2016
On Friday, 8 April 2016 at 13:44:17 UTC, Steven Schveighoffer wrote:On 4/8/16 9:31 AM, Daniel Kozak wrote:Even so, you shouldn't be able to make a local alias to private symbol from a different module.On Friday, 8 April 2016 at 13:28:15 UTC, Daniel Kozak wrote:Someone just filed this morning: https://issues.dlang.org/show_bug.cgi?id=15896[...]Btw: import a : Foo; Foo f1; // works OK even if Foo is privateOr even worse import a : Foo; import b; Foo f1; // works OK use a.FooNote, import rules here say a.Foo is now a LOCAL symbol. It's like you did: import a; alias Foo = a.Foo; This trumps any other imports. This is a long-standing rule that was not implemented properly in previous versions. You can get the old behavior back I think by doing -transition=import for dmd. -Steve
Apr 08 2016
On 4/8/16 2:03 PM, ZombineDev wrote:On Friday, 8 April 2016 at 13:44:17 UTC, Steven Schveighoffer wrote:On 4/8/16 9:31 AM, Daniel Kozak wrote:Sure, but the overloading behavior is expected is all I was saying. If a.Foo was not private, then the behavior above should be expected. The impression I get from the OP is that he thinks it's a further error. -SteveEven so, you shouldn't be able to make a local alias to private symbol from a different module.Or even worse import a : Foo; import b; Foo f1; // works OK use a.FooNote, import rules here say a.Foo is now a LOCAL symbol. It's like you did: import a; alias Foo = a.Foo; This trumps any other imports. This is a long-standing rule that was not implemented properly in previous versions. You can get the old behavior back I think by doing -transition=import for dmd.
Apr 12 2016
On Tuesday, 12 April 2016 at 11:42:08 UTC, Steven Schveighoffer wrote:On 4/8/16 2:03 PM, ZombineDev wrote:Ah ok, I see where you're coming from.On Friday, 8 April 2016 at 13:44:17 UTC, Steven Schveighoffer wrote:[...]Sure, but the overloading behavior is expected is all I was saying. If a.Foo was not private, then the behavior above should be expected. The impression I get from the OP is that he thinks it's a further error. -Steve[...]Even so, you shouldn't be able to make a local alias to private symbol from a different module.
Apr 12 2016