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

Traits with Duplicate Names in Function Signatures are Allowed #3214

Closed
sskeirik opened this issue Jul 23, 2022 · 2 comments
Closed

Traits with Duplicate Names in Function Signatures are Allowed #3214

sskeirik opened this issue Jul 23, 2022 · 2 comments

Comments

@sskeirik
Copy link

sskeirik commented Jul 23, 2022

Describe the bug
On master branch, when a contract contains a trait definition like the following:

(define-trait double-method (
  (foo (uint) (response uint uint))
  (foo (bool) (response bool bool))
))

Then only the last copy of foo is kept as part of the processed trait's definition.
This means that we can then successfully launch a contract like the following:

(impl-trait 'SP8CW062DS1XAZJJXWKSM9EMMDD51BRVFMY8MBX6.double-trait.double-method)
(define-read-only (foo (x bool)) (ok x))

Steps To Reproduce
If the first contract is stored in a file double-trait.clar and the second contract is stored in a file impl-double-trait.clar, then the CLI invocation to test would be:

clarity-cli initialize initial-allocations.json vm-state.db
clarity-cli launch SP8CW062DS1XAZJJXWKSM9EMMDD51BRVFMY8MBX6.double-trait double-trait.clar vm-state.db
clarity-cli launch SP8CW062DS1XAZJJXWKSM9EMMDD51BRVFMY8MBX6.impl-double-trait impl-double-trait.clar vm-state.db

Expected behavior
I expect that the type checker will reject contracts with traits that contain two function signatures with the same name, even if they are identical otherwise.

Environment (please complete the following information):

Additional context
N/A

@jcnelson
Copy link
Member

Thanks for your report! We're looking into it. A proper fix would be to address this in the 2.1 upgrade, but in all likelihood the tooling could also warn against this.

obycode added a commit that referenced this issue Sep 6, 2022
A trait definition which includes more than one method with the same
name should report an error.

fixes: #3214
obycode added a commit that referenced this issue Sep 6, 2022
A trait definition which includes more than one method with the same
name should report an error.

fixes: #3214
@jcnelson
Copy link
Member

jcnelson commented Nov 8, 2022

Fixed by #3251

@jcnelson jcnelson closed this as completed Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants