#7340 Has made it a compile error to have variables with identical names in classes. This means classes that previously did this (probably by mistake) will need to be rewritten.
A {
var a, a; // <-- now a compile error
}
This is obviously wrong above, but when you have inheritance things gets less obvious — this is also where the bugs start arising!
A {
var <a = 1;
getA { ^a }
}
B : A {
var <a = 2;
getA { ^a } // << turns out this 'a' is A.a, not B.a.
}
// as expected
A().a // 1
A().getA // 1
// not as expected
B().a // 2 // << yet this one is B.a ??
B().getA // 1 // << A.a
This is now a compile time error and the class library will not compile.
ERROR: Found duplicate instance variable name 'a'
in file '/home/jordan/.repo/SuperCollider/SCClassLibrary/Common/Core/Object.sc'
line 7 char 7:
var <a = 2;
getA { ^a }
Fixing this is left up to the author…
…but, hopefully, this is trivial and you can just remove the duplicate.
Just wanted to announce this somewhere and give people a heads up that this change is incoming.
If anyone finds a duplicate that isn’t trivial to fix, do let me know and I will see what can be done about it!
Some things to watch out for:
- Read and write access, what happens when the access is different, which variable did it alter previously?
super.newCopyArgs, which variable was actually getting the value?- Serialisation/archiving what happened previously?
If anyone finds some code where they actually relied on this behaviour, please reach out as well, it would be good to see if we can find a work around.
Jordan