Solidity has released v0.5.0 of the language.
The Solidity repo utilizes its Github projects really well, and most of the code that I had done before was tackling some basic issues that were needed to get the next version out.
Incredibly, I ended up being thanked on the 0.5.0 release. I didn’t expect it but it happened. I really enjoy spending time in that repo, everyone is very intelligent and very kind.
Now onto the issue.
0.5.1 is the next update, and there’s an issue thats opened up regarding code refactoring. Made up of many sub issues, basically the goal is to enhance the performance of the language and to remove redundancy. Here’s one of the sub issues I worked on.
When a function is declared with an
override remove the redundant
I’d realized before starting this relatively major refactoring (36 pages changed), that I had screwed up my repository. I had built from source following the Solidity instructions, and I had built my original repo that worked on the three other issues in Powershell on Windows. I had ended up with around 500+ build files that were shown as changes that needed to be added to Git.
My previous issues were small in size, working mostly in 1 to 2 files, so it wasn’t a problem to avoid adding them. The issue came from needing to make sure I properly found and removed every instance of
virtual partnered with an
override. Having so many changed files would make it difficult for me to navigate and understand which files I needed to add, and which I didn’t. A lot of unecessary clutter.
Here’s how you avoid that issue if you are a Windows user.
Important: run all of these in Command Prompt, not Powershell.
mkdir buildfrom root of the repo
cmake -G "Visual Studio 15 2017 Win64" ..
cmake --build . --config RelWithDebInfo
.\build\test\RelWithDebInfo\soltest.exe -- --no-ipc --no-smt
The next issue I ran into was replacing the redundant statement. I had to remove
virtual but only if there was an
override following it. Following cppreference, it seemed to not negatively affect the virtual-ness of a function if there was only
Solidity being a language, you get quite worried about accidentally introducing some unforeseen vulnerability in the language. Especially since it handles real, valuable currency on a daily basis.
VSCode is the editor I’m using at the moment.
CTRL+SHIFT+F nets you a repo-wide search and extends to a replace functionality. You can write which files to ignore as well. Now, you can extend this search with a regex toggle which was extremely useful for me working on this issue.
But there was an unforseen limitation of VSCode’s replacement functionality. Let me break down the issue:
virtual.*override, meaning match any character repeated 0 or more times.
virtual function name blah override;I want to keep the middle part and remove the virtual
.*override| Replace with
virtual function name blah override;——Becomes——->
.*override;The regex becomes part of the replacement rather than keeping the middle part and removing the virtual. This happens no matter what.
Ctrl+F) and replace by doing:
That works but I had to manually analyze that the highlighted repo search matches did in fact contain override, which some of them didn’t.
I believe this could be remedied by adding this functionality to VSCode, because I reckon I’m not the only one who ran into this case before. I also accidentally removed a virtual from an exception that was needed but the maintainers fixed that (thanks).
Anyways, onto the solution.