Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Err-returning function losing wrapped value #475

Open
matteojug opened this issue Aug 16, 2024 · 0 comments
Open

Err-returning function losing wrapped value #475

matteojug opened this issue Aug 16, 2024 · 0 comments
Assignees

Comments

@matteojug
Copy link
Contributor

I couldn't exactly identify what is the issue, as the following test (with the commented edits) show different failures:

  • as is: the compiled version seems to lose the inner value of the err:
compiled:    Ok(Some(Tuple(TupleData { type_signature: TupleTypeSignature { "fn": (response UnknownType (list 1 (string-utf8 0))), "mymap": (optional UnknownType),}, data_map: {ClarityName("fn"): Response(ResponseData { committed: false, data: Sequence(List(ListData { data: [Sequence(String(u""))], type_signature: ListTypeData { max_len: 1, entry_type: SequenceType(StringType(UTF8(StringUTF8Length(0)))) } })) }), ClarityName("mymap"): Optional(OptionalData { data: None })} })))
interpreted: Ok(Some(Tuple(TupleData { type_signature: TupleTypeSignature { "fn": (response UnknownType (list 1 (string-utf8 3))), "mymap": (optional UnknownType),}, data_map: {ClarityName("fn"): Response(ResponseData { committed: false, data: Sequence(List(ListData { data: [Sequence(String(u"foo"))], type_signature: ListTypeData { max_len: 1, entry_type: SequenceType(StringType(UTF8(StringUTF8Length(3)))) } })) }), ClarityName("mymap"): Optional(OptionalData { data: None })} })))
  • uncommenting the map-set line: compiled: Err(Unchecked(InvalidCharactersDetected)) (interpreted one stays correct)
  • uncommenting the map-set line + changing map-get to fetch key 1 ((map-get? mymap 1)): test passes
#[test]
fn something_funny() {
    crosscheck_compare_only(
        r#"
        (define-map mymap int int)
        (define-private (somefn)
            (begin 
                ;; (map-set mymap 0 99)
                (err (list u"foo"))
            )
        )
        { fn: (somefn), mymap: (map-get? mymap 0) }
        "#
    );
}
@saralab saralab added this to the WASM Testnet Preview milestone Aug 26, 2024
@Acaccia Acaccia self-assigned this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: 💻 In Progress
Development

No branches or pull requests

3 participants