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

Empty Messages are pushed on stack as empty tuples [] #1199

Open
1 task done
novusnota opened this issue Dec 17, 2024 · 0 comments
Open
1 task done

Empty Messages are pushed on stack as empty tuples [] #1199

novusnota opened this issue Dec 17, 2024 · 0 comments
Labels
bug Something isn't working or isn't right scope: codegen Code generation, a.k.a. compiler backend
Milestone

Comments

@novusnota
Copy link
Member

novusnota commented Dec 17, 2024

Are you using the latest released (or pre-released, a.k.a. "next") version?

  • I'm using the latest Tact version

Tact source code

import "@stdlib/deploy";

// Empty Message
message(7) Seven {}
asm fun pushSeven(msg: Seven) { }

// Message with one field
message(8) NotSeven { but: Int }
asm fun pushNotSeven(msg: NotSeven) { }

// Utility
asm fun drop() { DROP }

contract Showcase with Deployable {
    receive("showcase") {
        dumpStack();
        pushSeven(Seven{}); // pushes []
        dumpStack();
        pushNotSeven(NotSeven{ but: 8 }); // pushes 8
        dumpStack();

        // To leave the stack as we've found it at the start of the function
        drop(); // dropping the tuple of Seven
        drop(); // dropping the `but` of NotSeven
    }
}

Relevant Tact/build system log output

# Pay attention to the values to the right of C{96...C7}

#DEBUG#: File showcase.tact:16:9:
#DEBUG#: dumpStack()
#DEBUG#: stack(3 values) : 500000000 C{96...C7} 0

#DEBUG#: File showcase.tact:18:9:
#DEBUG#: dumpStack()
#DEBUG#: stack(4 values) : 500000000 C{96...C7} 0 []

#DEBUG#: File showcase.tact:20:9:
#DEBUG#: dumpStack()
#DEBUG#: stack(5 values) : 500000000 C{96...C7} 0 [] 8

What happened?

No response

What did you expect?

Instead of the following:

(tuple) $Seven$_constructor_() inline {
    return empty_tuple();
}

Tact can produce:

() $Seven$_constructor_() inline {
    return ();
}

Steps to reproduce

No response

How do you run Tact?

Blueprint, Tact CLI

Anything else?

This is especially inconvenient when working with values that cannot be expressed in the Tact's current type system, such as tuples: #1127 (comment)

@novusnota novusnota added the bug Something isn't working or isn't right label Dec 17, 2024
@anton-trunov anton-trunov added the scope: codegen Code generation, a.k.a. compiler backend label Dec 17, 2024
@anton-trunov anton-trunov added this to the v1.6.0 milestone Dec 17, 2024
@anton-trunov anton-trunov modified the milestones: v1.6.0, v1.7.0 Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or isn't right scope: codegen Code generation, a.k.a. compiler backend
Projects
None yet
Development

No branches or pull requests

2 participants