tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
280 stars 56 forks source link

Messages with the same opcodes are not detected #482

Closed anton-trunov closed 2 days ago

anton-trunov commented 3 days ago

Consider the following Tact code:

message(1) Msg1 {}
message(1) Msg2 {}

contract Example {
    receive(msg: Msg1) { }
    receive(msg: Msg2) { }
}

The message opcode clash results in the following incorrect FunC code that essentially ignores the Msg2 receiver.

;; Parse incoming message
int op = 0;
if (slice_bits(in_msg) >= 32) {
    op = in_msg.preload_uint(32);
}

;; Receive Msg1 message
if (op == 1) {
    var msg = in_msg~$Msg1$_load();
    self~$Example$_internal_binary_Msg1(msg);
    return (self, true);
}

;; Receive Msg2 message
if (op == 1) {
    var msg = in_msg~$Msg2$_load();
    self~$Example$_internal_binary_Msg2(msg);
    return (self, true);
}