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

generated vars use common names

Open pvetere opened this issue 3 years ago • 0 comments

In some cases (such as python), the generated bindings make use of local variables such as "i", "len", and "base". If you use these names in your WIT file as arguments, then you get an error. For example, consider the following WIT file:

power-of: func(base: s32, exp: s32) -> s32

Then try to generate bindings like this and notice the output:

% wit-bindgen wasmtime-py --import power.wit
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "name `base` already defined"', crates/gen-wasmtime-py/src/lib.rs:868:34

The generated code should use more obfuscated names to reduce the potential for this kind of naming collision.

pvetere avatar Jul 18 '22 19:07 pvetere