solidity
solidity copied to clipboard
Remove support for the catch all (*) in the using statement
Does the using MyLIb for *; statement saves that much typing/space as opposed to clearly typing out the intended types?
There are some types you cannot name but for which you can add still functions with *. Most notably literals:
library Math {
function add(uint a, uint b) internal returns (uint) {
return a + b;
}
}
contract C {
using Math for uint;
function f() public returns (uint) { return 2.add(2); } // Error: Member "add" not found or not visible after argument-dependent lookup in int_const 2.
}
contract D {
using Math for *;
function f() public returns (uint) { return 2.add(2); } // OK
}
I think that should be solved in a nicer way (i.e. having a rationalnumber type), than this abuse :)
Agreed. I think that * is a bad practice in general. Just wanted to point out we probably cannot remove it without providing a replacement for this. Unless it turns out that no one knows about this trick and therefore no one uses it :)
Unless it turns out that no one knows about this trick and therefore no one uses it :)
Now they certainly know about it 😅
I'm fine with requiring to be explicit, but maybe we should ask if this breaks anything.
Oh and we should allow ... for {uint, string}; in this case, i.e. providing a list of types.
Oh and we should allow
... for {uint, string};in this case, i.e. providing a list of types.
That probably is a good idea.
We should/could check if implicit conversions are still possible on the self type as long as all types are explicitly listed in the using statment, i.e. using L.add for {uint8, uint16, ...}; allows a single implementation of the SafeMath add function.
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.