Skip to content

Compiler issues #1

Description

@xunilrj

Sway compiler can run into a memory flow error (see issues/sway_memory_overflow/) or a memory overlap error (see issues/sway_memory_write_overlap/)

These do not happen anymore on master.

Sway fails to compile due to a type check error occuring when a tuple of a single element is decoded as the decoding will not produce a tuple but only the single element it contained. (see issues/sway_tuple_compiler_error/)

This is indeed correct, because the generated code is using the wrong types. (str[2]) is not a tuple. For a unary tuple we need a trailing comma: (str[2],). The correct version is

let v: (str[2],) = (__to_str_array("*�"),);
        
    let mut buffer = Buffer::new();
    let mut encoded = v.abi_encode(buffer).as_raw_slice();
    log(encoded);

    let decoded = abi_decode::<(str[2],)>(encoded);
    log(from_str_array(v.0) == from_str_array(decoded.0));

And this version compiles.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions