wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

Types from WITX `use` statements are double included

Open Asraelite opened this issue 4 years ago • 1 comments

Currently when the same type is imported multiple times into a WITX module by use statements, an error occurs saying that the type is defined twice.

Example:

a.witx

type foo = u8 

b.witx

use { foo } from a

c.witx

use { foo } from a
use * from b

> Error: type "foo" defined twice.

It would be nice there was some way of handling this so that multiple WITX files could all import from one common source, while still importing from each other with star imports. This is especially important if you have the same type used in many different files, e.g. error codes.

Asraelite avatar Jul 14 '21 20:07 Asraelite

Makes sense to me to implement! Right now the collision check is quite simple, purely based on names, but I agree that if the duplicate-ly imported name exactly matches the previous import (same source definition and all) I think it makes sense to allow that and keep it working.

alexcrichton avatar Jul 14 '21 20:07 alexcrichton

The use feature has been temporarily removed, so I'm going to close this. Fixing this and other related issues will happened with a re-introduced version of use.

alexcrichton avatar Nov 15 '22 22:11 alexcrichton