Skip to content

lang: Handle arrays with const as length#968

Merged
armaniferrante merged 15 commits intosolana-foundation:masterfrom
tomlinton:tomlinton/idl-const-array-size
Dec 23, 2021
Merged

lang: Handle arrays with const as length#968
armaniferrante merged 15 commits intosolana-foundation:masterfrom
tomlinton:tomlinton/idl-const-array-size

Conversation

@tomlinton
Copy link
Contributor

@tomlinton tomlinton commented Nov 2, 2021

Replaces variables in array definitions with their value. One clear limitation is that if the same const is declared in different places in the crate with different values this might not use the correct one. Hopefully an uncommon case, but definitely keen on suggestions!

Closes #335
Closes #294

@tomlinton
Copy link
Contributor Author

I updated this to panic with an error if there is another const in the crate with the same name that is usize and has a different value. I think that is preferable.

@tomlinton tomlinton force-pushed the tomlinton/idl-const-array-size branch 2 times, most recently from 7d0251a to d580425 Compare December 4, 2021 03:05
@tomlinton tomlinton changed the title lang: Handle arrays with variable as length lang: Handle arrays with const as length Dec 4, 2021
@armaniferrante armaniferrante merged commit 51aeb08 into solana-foundation:master Dec 23, 2021
@armaniferrante
Copy link
Contributor

Thank you for this @tomlinton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lang: Arrays can't be defined with variable as the length IDL generation doesn't seem to handle const expressions for array dimensions

2 participants