wac icon indicating copy to clipboard operation
wac copied to clipboard

Provide option to downgrade `unknown import` errors to warnings

Open salmans opened this issue 1 year ago • 1 comments

When instantiating a component, it's probably safe to supply it with additional imports that aren't declared in its world. For example, consider a component that declares an import foo in its world but it doesn't use foo in its implementation. Consequently, foo won't be present in the component's WIT that is generated by witgen, which will cause a confusing unknown import error by wac. I think downgrading the error to a warning would be enough to let the user know about a potential logical error while allowing wac to run successfully.

salmans avatar Feb 29 '24 22:02 salmans

I'm also running into this issue. For languages with good dead code elimination like Rust the resulting component binary might not reflect the exact targeted world if the any imports are not used - those imports will simply be removed. It would be nice if supply imports that don't exist was simply a warning as supplying an import that doesn't exist is essentially a noop.

Of course, this will largely go away with a programatic API where the actual world of the component can be dynamically inspected and only imports it actually requires can be provided.

rylev avatar Mar 22 '24 14:03 rylev