#bizarre behavior from zig-lsp in vscode

1 messages · Page 1 of 1 (latest)

teal spade
#

bit of "backstory":

i'm trying something i've never tried before, making something like a "compressor" of strings. not using any algorithm or anything (yet), just using less bits by only storing only the characters used at compile time

i.e if a string contains "hello world" and another contains "bello world" then the characters stored in constant memory would be h,e,l,o,w,r,d,b and they would be "decompressed" at runtime (if needed to be in u8 ascii format), resulting in the characters being only 3 bits each instead of 8 and "expanded" to their original value on the stack

bit of a useless project and the code has plenty of issues already, but it doesn't really matter, just something i'm doing for practice to learn more about memory, stack, and zig in general. issues will be ironed out after i have a basic concept going

now the problem: in the first picture, you can see what my root.zig looks like. at the top of the comptimeCompress function, you can spot a variable which has a signature of rs var out: [text.len]CompressedCharacter = undefined;

when trying to write to this variable later however (2nd pic), instead of being given the fields of the struct CompressedCharacter, i'm given the fields of the enum compressed_character... am i missing something or is this really bizarre behavior?

barren plover
#

that is weird, but you wouldn't get field completions in that context anyway; you have to start a struct literal first

teal spade
rapid marten
#

You're talking about compression, and what you've described is basically huffman coding, where you build the decoding table at comp-time and embed it in the app. leveraging the existing knowledge and implementations could give you a leg up in realizing what you're after.

barren plover
hearty talon
#

zls has snippets for field completions like .foo -> .{ .foo = , this should work fine

barren plover
#

oh interesting

teal spade
#

i think for now i'll probably keep tinkering and trying to figure it out myself and then i'll improve it with existing knowledge

#

just to maximize the learning potential

teal spade