Skip to content

str produces unexpected pointer behavior #226

@LunaStev

Description

@LunaStev

When using the & operator on a str variable, Wave produces unexpected results.
Currently, str is internally treated as an i8*, so applying & creates a pointer-to-pointer (i8**).
This leads to confusing output instead of the expected string address or string content.


Steps to Reproduce

  1. Create a file test/test40.wave with the following code:
fun main() {
    var msg: str = "Hello";
    var msg_ptr: ptr<str> = &msg;
    var msg_ptr2: ptr<i8> = &msg;

    println("{}", msg_ptr);
    println("{}", msg_ptr2);
}
  1. Run
cargo run -- run test/test40.wave
  1. Output
0x7fffdda81078
�"e

Expected Behavior

  • &msg should either be:
    • Valid pointer to the string data ("Hello"), or
    • Disallowed by the compiler if str is already a pointer type.

Actual Behavior

  • &msg creates a pointer-to-pointer (i8**), resulting in unexpected values being printed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA problem that causes incorrect behavior or crashes.good first issueIssues that are good for newcomers or first-time contributors.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions