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

Cannot have a contract with a type and method of the same name #828

Closed
paulbellamy opened this issue Jan 17, 2023 · 1 comment · Fixed by #839
Closed

Cannot have a contract with a type and method of the same name #828

paulbellamy opened this issue Jan 17, 2023 · 1 comment · Fixed by #839
Assignees
Labels
bug Something isn't working

Comments

@paulbellamy
Copy link
Contributor

For example, if the getter method in https://github.com/stellar/soroban-examples/blob/main/custom_types/src/lib.rs were named state, you'd get an error. This seems like a common pattern people would hit (especially with the 10char limit for method names).

@paulbellamy paulbellamy added the bug Something isn't working label Jan 17, 2023
@leighmcculloch leighmcculloch self-assigned this Jan 25, 2023
@leighmcculloch
Copy link
Member

leighmcculloch commented Jan 26, 2023

An example of the error that happens when giving a type and function the same name is:

error[E0428]: the name `__SPEC_XDR_STATE` is defined multiple times
  --> soroban-sdk/src/tests/contract_overlapping_type_fn_names.rs:12:1
   |
5  | #[contracttype]
   | --------------- previous definition of the value `__SPEC_XDR_STATE` here
...
12 | #[contractimpl]
   | ^^^^^^^^^^^^^^^ `__SPEC_XDR_STATE` redefined here

leighmcculloch added a commit that referenced this issue Jan 26, 2023
### What
Change the names of the static variables that contain the spec XDR to
include a type or function qualifier for the kind of entry the spec
contains.

### Why
To allow same named types and functions in contracts. When a type and
function have the same name today they result in two static variables
that have the same names. Adding a qualifier to what they are to those
variables names will stop them from colliding.

Close #828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants