anchor icon indicating copy to clipboard operation
anchor copied to clipboard

lang: Add `space` attribute to the InitSpace macro

Open Aursen opened this issue 11 months ago • 5 comments

Problem

#2765

Summary of changes

  • Add attribute space to InitSpace macro

Aursen avatar Mar 21 '24 10:03 Aursen

@Aursen is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 21 '24 10:03 vercel[bot]

Thanks. What happens when the space is not enough?

#[space(2)]
pub data: Vec<u64>,

It will not check if the length is valid. This attribute is designed to give the user freedom

Aursen avatar Mar 22 '24 08:03 Aursen

Freedom to run into a guaranteed error in runtime? It feels like we have enough information to make this a compile error — what do you think?

acheroncrypto avatar Mar 22 '24 15:03 acheroncrypto

Freedom to run into a guaranteed error in runtime? It feels like we have enough information to make this a compile error — what do you think?

The only issue with this, when a user uses const or other thing like this for the value of space we can't verify the space

Aursen avatar Apr 02 '24 11:04 Aursen

Yeah, I don't think it needs to be perfect, just the easy parts we can easily handle. It's also not required to merge this, but it would be an improvement over the current impl.

acheroncrypto avatar Apr 02 '24 19:04 acheroncrypto