bytecodealliance / bytecodealliance/wasm-tools
Improve span information for expanded types
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
Modules which look like:
```wasm
(module
(import "" "" (func))
)
```
get automatically expanded to:
```wasm
(module
(type (func))
(import "" "" (func (type 0)))
)
```
During the expansion process for doing this, though, insertion of the new `(type ...)` uses `Span::from_offset(0)` for much of its span information. The reason for this is that the `TypeUse` here specifically doesn't have a span within `FunctionType` and namely in the example above there's nothing to assign the span to (ideally it's sort of `func`). This is also the case with the component model for:
```wasm
(component
(type (option (list u8)))
)
```
getting expanded to
```wasm
(component
(type (list u8))
(type (option 0))
)
```
Here though we don't keep track of the span of the `list` keyword and otherwise there isn't great span information to insert.
I don't know really how important this is to fix. I don't think it's actually possible to get any errors which use these spans, so it could be entirely benign to leave all these spans as 0. I still feel though that it would probably be best to figure out a good way to thread through a proper span here.
Contributor guide
Assessment
This issue has not been assessed yet.