Open alex-s168 opened 6 days ago
Yeah, that error message sucks. LM doesn't support inline compound typedefs or untagged unions yet.
type UmbraShortLong (UmbraShort( arr:Array<U8,12> )) | (UmbraLong(prefix: Array<U8, 4> , ptr: U8[]));
type Umbra (Umbra( len:U32, backing:UmbraShortLong ));
or
type Umbra (UmbraShort( len:U32, arr:Array<U8,12> )) | (UmbraLong( len:U32, prefix: Array<U8, 4>, ptr: U8[]));
I'm getting a really weird error:
Pattern Match Failure at File: PLUGINS/BACKEND/C/compile-expr-direct.lm Line: 89 Column: 14
Hmm, this is a nasty error. LM does not excel at optimizing custom data structures atm. Especially when interacting with the "match" destructuring primitive.
Match currently tries to dereference pointers by default to permit further destructuring or to create useful values, which is not at all what you are trying to do.
I am going to
field accessors directly still work (.prefix u)
if you want to destructure manually. You can also avoid this error in match by not binding anything (UmbraLong( _ ))
However, I would also suggest sitting on this for a while, as what you are trying to do will be better supported in the near future. The C backend is literally about 2 weeks old.
Your code is very idiomatic. Thanks for taking the time to study so much.
a lot of good ideas coming from this
I was trying to implement a (not really efficient) umbra string type like this:
but I get this error and I don't know why: