FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.64k stars 5.36k forks source link

Custom type (struct/enum) smuggled into IR illegally via tuples. #1556

Closed otrho closed 2 years ago

otrho commented 2 years ago

This is from @Braqzen in #1401 where it's not really related to that issue, so I'm recreating it here.

The following

contract;

abi MyContract {
    fn bug1(param: (Person, u64)) -> bool;
    fn bug2(param: (Location, u64)) -> bool;
}

struct Person {
    age: u64
}

enum Location {
    earth: ()
}

impl MyContract for Contract {
    fn bug1(param: (Person, u64)) -> bool {
        true
    }

    fn bug2(param: (Location, u64)) -> bool {
        true
    }
}

generates the error: 1

The issue is with the tuple taking a struct / enum type. The u64 works as expected. Using other unsigned integers, str[<size>], bool and b256 types works as expected when passed into the tuple.

mohammadfawaz commented 2 years ago

+ 1 for the title 😆

emilyaherbert commented 2 years ago

I believe that the type engine and monomorphization improvements from #579 will completely (or at least partially), fix this.

emilyaherbert commented 2 years ago

Just confirmed---it is fixed by #579

otrho commented 2 years ago

Thanks -- when you mentioned it in the sync call I had my hopes up. :slightly_smiling_face: