-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement string.concat() and bytes.concat() #1590
Conversation
04ced55
to
d7aee75
Compare
Codecov Report
@@ Coverage Diff @@
## main #1590 +/- ##
==========================================
+ Coverage 87.57% 87.65% +0.08%
==========================================
Files 133 133
Lines 64217 64300 +83
==========================================
+ Hits 56236 56363 +127
+ Misses 7981 7937 -44
|
9ea0533
to
321a3e4
Compare
321a3e4
to
7c81e98
Compare
Removing |
As such I don't think there is need for deprecation and eventual removal. I've added an entry to |
7c81e98
to
341fcdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I just see some potential to optimize the concatenation into a no-op when one operand is an empty constant:
function f(string a) public returns (string) {
return string.concat(a, "");
}
block0: # entry
ty:string %a = (arg #0)
return (builtin Concat ((arg #0), (alloc string uint32 0 "")))
341fcdf
to
8a2f9c0
Compare
Nice, good catch. I've fixed this and added a test case. |
This is what solc implements. Solang has implement a + b for string concatenation, which this PR removes. Fixes: hyperledger-solang#1558 Signed-off-by: Sean Young <sean@mess.org>
8a2f9c0
to
e06deb1
Compare
We don't know if it is not used much. There is no way to prove it. The solana examples is a small set of what people use Solang for. Polkadot also support this feature. Instead of deprecating then, what do you think of suggesting people to use |
Co-authored-by: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com> Signed-off-by: Sean Young <sean@mess.org>
I've added a diagnostic for this. I think it's useful in general for folks when they may try to concatenate two strings. |
This is what solc implements. Solang has implement a + b for string concatenation, which this PR removes. Fixes: hyperledger-solang#1558 Signed-off-by: Sean Young <sean@mess.org> Co-authored-by: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com>
This is what solc implements. Solang has implement a + b for string concatenation, which this PR removes.
Fixes: #1558