Repository navigation
Replace invalid characters with _ in wat-writer - #687
Conversation
We should add a way to express all names that are valid in the binary format in the text format. Until then, it's better to be able to produce a valid `wat` file. See issue #685.
| 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; | ||
|
|
||
| // This table matches the characters allowed by wast-lexer.cc for `symbol`. | ||
| // The disallowed printable characters are: "(),;[]{} and <space>. |
There was a problem hiding this comment.
@binji thanks a lot for investigating! I was hoping a few additional characters would be allowed in the lexer, but oh well.
@alexcrichton and @shepmaster for your reference the above characters will be replaced by_ in wasm2wat. Out of these characters I know (),[] and <space> are used in rust unmangled symbol names. Below are a few examples I was worried about but now that I see them it doesn't seem too bad.
<(i32, i32) as wasm::Wasm>::wasm::hfc09b9ea108eba04
<_i32__i32__as_wasm::Wasm>::wasm::hfc09b9ea108eba04
<&'a T as core::fmt::Debug>::fmt::h273375ad95a1eb7b
<&'a_T_as_core::fmt::Debug>::fmt::h273375ad95a1eb7b
<core::fmt::Write::write_fmt::Adapter<'a, T> as core::fmt::Write>::write_char::h25e7e7a8edf51d28
<core::fmt::Write::write_fmt::Adapter<'a__T>_as_core::fmt::Write>::write_char::h25e7e7a8edf51d28
<std::error::<impl core::convert::From<alloc::string::String> for alloc::boxed::Box<std::error::Error + core::marker::Sync + core::marker::Send + 'static>>::from::StringError as std::error::Error>::description::hdf1479d893d74cf2
<std::error::<impl_core::convert::From<alloc::string::String>_for_alloc::boxed::Box<std::error::Error_+_core::marker::Sync_+_core::marker::Send_+_'static>>::from::StringError as std::error::Error>::description::hdf1479d893d74cf2
|
I've been thinking more about long term solutions and have a few ideas to float. I've tried to combine existing constructs defined in the spec so that existing code can be leveraged. At call sites, if At the function declaration, to use the comment trick we would need to move the type, param, and result fields to the next line. It would look like this: Alternatively, it may be possible to add a I think the main advantage of this option is that it would make it easier when parsing a |
Personally I think it should, in general. Since you can express short varints with a longer length they won't necessarily by byte identical, but they'll mean the same thing. The broader topic of round-tripping custom sections came up here as well: WebAssembly/design#1153. Using the annotation syntax there, it might look like: |
|
Gonna land this for now since it is better than producing a bad |
We should add a way to express all names that are valid in the binary
format in the text format. Until then, it's better to be able to
produce a valid
watfile.See issue #685.