If I have a canister that contains a stable Trie, I get the following message every time I try to deploy, even if I’ve made no changes since the last time I deployed:
WARNING!
Stable interface compatibility check failed for canister 'stability'.
Upgrade will either FAIL or LOSE some stable variable data.
.../ic-projects/stability/.dfx/local/canisters/stability/stability.old.most:2.39-2.40: syntax error [M0001], unexpected token '/', expected one of token or <phrase> sequence:
}
<typ_args>?
; seplist(<typ_field>,<semicolon>)
or <typ>
. <id>
-> <typ_nobin>
and <typ>
Do you want to proceed? yes/No
I have to answer “yes” every time I want to deploy, even if no stability-disrupting changes have been made. The only way I can get dfx to not ask me is to delete the .dfx folder or restart dfx with --clean specified, but then of course I run into the same issue the next time I try to deploy. Possibly the error in the .old.most file mentioned in the warning is causing the comparison to consider any changes as stability-breaking.
Here are the contents of stability.old.most:
type Branch<K, V> = {left : Trie<K, V>; right : Trie<K, V>; size : Nat};
type Leaf<K, V> = {keyvals : AssocList/1<Key<K>, V>; size : Nat};
actor {
stable var test :
{#branch : Branch<Nat, Nat>; #empty; #leaf : Leaf<Nat, Nat>}
};
This happens with the default project created with “dfx new” under dfx 0.9.2 if a stable variable like the following is in the actor, even if it’s not new or changed between deploys:
stable var test : Trie.Trie<Nat, Nat> = Trie.empty();
But not when the stable variable is a Nat, for example:
stable var test : Nat = 1;