hyperledger-solang / solang

Solidity Compiler for Solana and Polkadot
https://solang.readthedocs.io/
Apache License 2.0
1.27k stars 215 forks source link

Bugfix: Variables declared in return param can have a storage location #1552

Closed xermicus closed 1 year ago

xermicus commented 1 year ago

Variables declared as return parameters can have a storage location too.

xermicus commented 1 year ago

It's also for unnamed variables?

seanyoung commented 1 year ago

It's also for unnamed variables?

Yes, you're right. I don't get how this could have worked before, we have been returning storage slots from functions.

Anyway looks good

xermicus commented 1 year ago

@seanyoung I think in practice this isn't noticeable on unnamed variables declared in the return parameters, because in that case the variable doesn't really exist until it's returned. It's sort of "shadowed" by something else, until the corresponding return statement is reached. And by then, the function already returned, so nothing can for example access the slot, where it would play a role. So it can't have consumers in the function local scope, hence we probably never noticed.

However, I agree, technically, it's still correct to set the storage location.