Skip to content
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

Incorrect metadata for overridden functions. #1623

Closed
TorstenStueber opened this issue Feb 19, 2024 · 1 comment · Fixed by #1624
Closed

Incorrect metadata for overridden functions. #1623

TorstenStueber opened this issue Feb 19, 2024 · 1 comment · Fixed by #1624
Assignees
Labels
polkadot Concerns the Polkadot target

Comments

@TorstenStueber
Copy link

Describe the bug
Whenever a method is overriden, Solang appends an underscore _ to the method name in the generated metadata file.

To Reproduce
After compiling the following file:

abstract contract Base {
    function test() public pure virtual returns (uint8) {
        return 42;
    }
}

contract TestA is Base {

}

contract TestB is Base {
    function test() public pure override returns (uint8) {
        return 42;
    }
} 

with Solang (latest release 0.3.3), the generated metadata file for TestA correctly calls the method test ("label": "test").

However, in contract TestB it is called test_ ("label": "test_").

Expected behavior
The metadata name is also test in the metadata for contract TestB.

This is also the behavior of the Solidity compiler (where the method is called test in both cases in the generated metadata).

Hyperledger Solang version
0.3.3

@xermicus xermicus self-assigned this Feb 19, 2024
@xermicus xermicus added the polkadot Concerns the Polkadot target label Feb 19, 2024
xermicus added a commit that referenced this issue Feb 28, 2024
#1624)

Closes #1623 

The basic idea of the algorithm checking whether a function name is
eligible for mangling or not is to mangle the name if that function is
publicly callable but the functions name appears multiple time in the
contract. But this doesn't account for virtual functions also appearing
more than one time in the same contract if they are overridden. With
this PR, we bail early if the function we are checking overrides,
marking only the single one non-overriding implementation as eligible
for mangling. Consequently, functions which override but do not overload
are no longer unnecessarily mangled.

Co-authored-by: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com>
@xermicus
Copy link
Contributor

@TorstenStueber thank you for reporting this to us. The bug should be fixed in #1624.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polkadot Concerns the Polkadot target
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants