Currently, the Wasm backend emits some downcasts of its own rather than fully relying on the presence of a Cast node. This causes:
- The IR to miss crucial information on when cast should be inserted
- The Wasm backend's downcast implementation to do more work than is necessary
Preferably, we would like to have Wasm's downcast helper to only cast between nullable and non-null types, since these kinds of casts cannot be represented in the IR.
A WIP implementation is available here: https://github.com/Derppening/mlscript/tree/enhance/more-casts-in-typed-ir. One major issue with the implementation is the large number of explicit Cast that are present in the diff - I suspect enabling typed-annotated let bindings (#547) may address some of this.
Currently, the Wasm backend emits some downcasts of its own rather than fully relying on the presence of a
Castnode. This causes:Preferably, we would like to have Wasm's downcast helper to only cast between nullable and non-null types, since these kinds of casts cannot be represented in the IR.
A WIP implementation is available here: https://github.com/Derppening/mlscript/tree/enhance/more-casts-in-typed-ir. One major issue with the implementation is the large number of explicit
Castthat are present in the diff - I suspect enabling typed-annotatedletbindings (#547) may address some of this.