-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix fn selector builder for custom types #17
Conversation
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.
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. |
cc @sezna |
Yes, this is how it works in Sway. And see Enum behavior right below it. |
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 |
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.
utACK
Can you file an issue to track creating some test vectors in the specs that both the compiler and SDKs can use?
Yup, that's a great idea! |
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.