Skip to content

str produces unexpected pointer behavior #226

Closed as not planned
Closed as not planned

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.

Activity

  1. added
    bug
    good first issue
    on Aug 19, 2025
  2. LunaStev commented on Aug 25, 2026

    @LunaStev
    MemberAuthor

    The original corrupted-output reproduction is stale: current builds print pointer values consistently. A narrower semantic defect remains—the compiler accepts ptr<i8> = &message even though &message has type ptr<str>. That current contract and its check/build regressions are tracked in #358. Closing this stale report in favor of the precise replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions