zig icon indicating copy to clipboard operation
zig copied to clipboard

Sema: implement @export for arbitrary values

Open mlugg opened this issue 2 years ago • 6 comments

mlugg avatar Mar 04 '23 14:03 mlugg

Needs a test. Probably a behavior test will be the simplest testing strategy.

andrewrk avatar Mar 04 '23 20:03 andrewrk

Well it turns out this just... crashes if you build as an exe through build_exe or test? Good thing you asked me to add a test I guess! EDIT: scrap that, my global cache was just doing some funny business

mlugg avatar Mar 04 '23 21:03 mlugg

And don't forget to test that the data was exported correctly as well! Another file could use extern to access the exported data.

andrewrk avatar Mar 05 '23 19:03 andrewrk

I was following the example of the rest of that file in not actually checking the value. But yes, it could be done - don't even need another file, just another container with an extern decl. If I add a check for this one, would you like me to add tests for the rest too? (Also, it seems like @extern is broken when you have an export of the same name, I'll look into that and open an issue if necessary.)

mlugg avatar Mar 05 '23 22:03 mlugg

I just realised I never tested what this does on global vars - marking WIP until I test that

mlugg avatar Mar 09 '23 14:03 mlugg

Oh it's actually fine, that runs via export not export_value, nice!

mlugg avatar Mar 09 '23 15:03 mlugg