-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
accounts/abi: resolve name conflict for methods starting with a number #26999
Conversation
Isn't this just pushing the edgecase a bit further away? What if we already have a method called EDIT: Ah then we'd get |
The edge case is variables starting with a number, this will crash the abigen. This PR fixes that, so a contract with |
accounts/abi/utils.go
Outdated
func ResolveNameConflict(rawName string, used func(string) bool) string { | ||
name := rawName | ||
if unicode.IsDigit(rune(name[0])) { | ||
name = fmt.Sprintf("%s%s", "m", name) | ||
} | ||
ok := used(name) | ||
for idx := 0; ok; idx++ { | ||
name = fmt.Sprintf("%s%d", rawName, idx) |
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.
This would also need to use the m
-prefixed version. So maybe you need to set rawName
to name
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.
Damn now I see it, thanks will add a test
If you had written a test you'd know that wasn't true :p |
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!
Oops? |
Co-authored-by: Martin Holst Swende <martin@swende.se>
|
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
Wait, I'm confused:
|
Aha so as @jsvisa mentioned, the problematic pattern is first
|
Seems we need to convert
|
I pushed a commit to rather than names starting with digits catch names starting with |
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've removed the now obsolete test
ethereum#26999) This adds logic to prepend 'M' or 'E' to Solidity identifiers when they would otherwise violate Go identifier naming rules. Closes ethereum#26972 --------- Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
ethereum#26999) This adds logic to prepend 'M' or 'E' to Solidity identifiers when they would otherwise violate Go identifier naming rules. Closes ethereum#26972 --------- Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
… a number (ethereum#26999)" This reverts commit 5b6fa97.
… a number (ethereum#26999)" This reverts commit 5b6fa97.
Its a very edge case, but this PR allows abigen to generate bindings for methods starting with a number
closes #26972