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

Fix fn selector builder for custom types #17

Merged
merged 2 commits into from
Dec 10, 2021
Merged

Conversation

digorithm
Copy link
Member

Before, the function selector used for methods with
custom types was being built as "my_func(MyStruct)".

This isn't the right approach, instead, it should be:
"my_func(s(field_1,field_2,...,field_n))".

This fixes the function selector builder to support the
right approach and it also greatly simplifies the whole
process.

Before, the function selector used for methods with
custom types was being built as `"my_func(MyStruct)"`.

This isn't the right approach, instead, it should be:
`"my_func(s(field_1,field_2,...,field_n))"`.

This fixes the function selector builder to support the
right approach and it also greatly simplifies the whole
process.
@digorithm digorithm added the enhancement New feature or request label Dec 10, 2021
@digorithm digorithm self-assigned this Dec 10, 2021
@adlerjohn
Copy link
Contributor

Does this functionality not exist in https://github.com/FuelLabs/sway?

@digorithm
Copy link
Member Author

Does this functionality not exist in https://github.com/FuelLabs/sway?

I don't know, I personally haven't seen this when I was exploring the Sway's codebase. But it's a big codebase... so I could've missed it.

@adlerjohn
Copy link
Contributor

cc @sezna

@sezna
Copy link

sezna commented Dec 10, 2021

Yes, this is how it works in Sway.

And see Enum behavior right below it.

@sezna
Copy link

sezna commented Dec 10, 2021

Should we abstract function selector logic since it is shared? Or is that too much of a hassle?

@digorithm
Copy link
Member Author

digorithm commented Dec 10, 2021

Should we abstract function selector logic since it is shared? Or is that too much of a hassle?

I would prefer to avoid premature abstraction (only 2 cases right now) at this stage. Especially that the way this logic is implemented in the compiler is not only different than the way I implemented it here (impl details only, not the logic itself, both are matching the specs) but it is also a bit more complex, as it seems to be holding a lot of context necessary for the compiler itself. It would be quite a bit of work right now to either (1) adapt fuels-rs to use the abstraction in the compiler or (2) abstract the logic so it would be used by both.

@digorithm digorithm marked this pull request as ready for review December 10, 2021 01:07
Copy link
Contributor

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Can you file an issue to track creating some test vectors in the specs that both the compiler and SDKs can use?

@digorithm
Copy link
Member Author

Yup, that's a great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants