CFLint
CFLint copied to clipboard
AVOID_USING_STRUCTNEW false positive with struct ordered
When declaring a ordered struct, I do:
a = structNew( "ordered" );
and cflint complains about the use of structnew. I don't see in the docs another way to declare it.
Good question. Here is the short form: a = {};
On Mon, Dec 10, 2018 at 5:55 AM David Sedeño [email protected] wrote:
When declaring a ordered struct, I do:
a = structNew( "ordered" );
and cflint complains about the use of structnew. I don't see in the docs another way to declare it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cflint/CFLint/issues/607, or mute the thread https://github.com/notifications/unsubscribe-auth/AFtZuwXalfW5gJ9IaVELRN-JDjjAsLRsks5u3j2WgaJpZM4ZLHlT .
@ryaneberly That does not initialize it as an ordered struct. There is a literal syntax for ordered structs (see #534), but that cannot be used for initializing an empty ordered struct.
Good point. Maybe that rule in lint should not fire if StructNew is used with parameters!
On Mon, Dec 10, 2018 at 5:30 PM KamasamaK [email protected] wrote:
@ryaneberly https://github.com/ryaneberly That does not initialize it as an ordered struct. There is a literal syntax for ordered structs (see #534 https://github.com/cflint/CFLint/issues/534), but that cannot be used for initializing an empty ordered struct.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cflint/CFLint/issues/607#issuecomment-445999274, or mute the thread https://github.com/notifications/unsubscribe-auth/AFtZuwvu_D3nMpe6cpeDuVH2jLPgAdA1ks5u3uCUgaJpZM4ZLHlT .
So I'm not sure how I missed this, but I just found that there actually is a way to declare an empty ordered struct using the literal syntax. It is:
var orderedStruct = [:]
or var orderedStruct = [=]
However, it produces a parse error due to #534.