tact-lang / tact

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

Compiling error: Function '__tact_dict_get_int_int' does not exist in imported FunC sources #722

Closed imartemy1524 closed 2 months ago

imartemy1524 commented 2 months ago

Problem

Trying to compile big project with many contracts dependencies, and getting next error:
Function '__tact_dict_get_int_int' does not exist in imported FunC sources Trait, where error is being thrown:

trait LockableAction{

    lockableAction: map<Int as uint64, Bool>;

    inline fun lock(userId: Int){
        self.lockableAction.set(userId, true);
    }
    inline fun unlock(userId: Int){
        self.lockableAction.del(userId);
    }

    inline fun requireNotLocked(userId: Int){
        require(self.lockableAction.get(userId) == null, "Please wait untill previous transaction finish!");
    }
}

Generated func code:

((int, slice, int, slice, cell, int, int), ()) $UserPost$_fun_requireNotLocked((int, slice, int, slice, cell, int, int) $self, int $userId) impure inline {
    var (($self'postId, $self'text, $self'ownerUserId, $self'master, $self'lockableAction, $self'likesCount, $self'dislikesCount)) = $self;
    ////////////////////////////////          |> error here 
    throw_unless(1151, null?(__tact_dict_get_int_int($self'lockableAction, 64, $userId, 1)));
    return (($self'postId, $self'text, $self'ownerUserId, $self'master, $self'lockableAction, $self'likesCount, $self'dislikesCount), ());
}

Steps to reproduce

git clone https://github.com/imartemy1524/ton-social -b tact-error
cd ton-social 
npm i
npx blueprint build # error here

Other comments

It seems, that this is the problem with Bool value type in map, because when one replaces map<Int as uint64, Bool> with map<Int as uint64, Int as uint8>, the problem fixes.

My temporary solution:

trait LockableAction{

    lockableAction: map<Int as uint64, Int as uint8>;

    inline fun lock(userId: Int){
        self.lockableAction.set(userId, 0);
    }
    inline fun unlock(userId: Int){
        self.lockableAction.del(userId);
    }

    inline fun requireNotLocked(userId: Int){
        require(self.lockableAction.get(userId) == null, "Please wait untill previous transaction finish!");
    }
}
anton-trunov commented 2 months ago

@imartemy1524 Let me thank you for such a well-written report! We will look into this asap. Incidentally, blueprint build should report a failure but it does not, I filed an issue here: https://github.com/ton-org/blueprint/issues/144