This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
cast mutable array to immutable array #579
Closed
Description
Hi,
The following code attempts to cast a mutable array to an immutable array, but traps at runtime:
(module
(type $ma (array (mut i32)))
(type $ima (array i32))
(func (param $a (ref $ma)) (result (ref $ima))
(local.get $a)
(ref.cast (ref $ima))
)
)
Use Case: I'm implementing strings as immutable arrays in my language. For operations like string append, I need to:
- Allocate a mutable array
- Write the characters
- Convert it to an immutable array
Questions:
- Is there a way to cast from mutable to immutable arrays?
- If not, what's the recommended approach for implementing immutable string operations?
Thanks for your help!
Metadata
Metadata
Assignees
Labels
No labels