Skip to content

Commit

Permalink
bugfix: fix for #3140 continued (#3143)
Browse files Browse the repository at this point in the history
Continues the saga of fixing #3140 by being more careful about deciding how to elide type bindings for prelude defined prims. 

c.f. https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/9?u=claudio
  • Loading branch information
crusso authored Mar 7, 2022
1 parent 860ff62 commit 318f181
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mo_types/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1397,9 +1397,9 @@ and pp_stab_sig ppf sig_ =
let ds =
let cs' = ConSet.filter (fun c ->
match Cons.kind c with
| Def ([], Prim p) when Cons.name c = string_of_prim p -> false
| Def ([], Any) when Cons.name c = "Any" -> false
| Def ([], Non) when Cons.name c = "None" -> false
| Def ([], Prim p) when string_of_con c = string_of_prim p -> false
| Def ([], Any) when string_of_con c = "Any" -> false
| Def ([], Non) when string_of_con c = "None" -> false
| Def _ -> true
| Abs _ -> false) cs in
ConSet.elements cs' in
Expand Down
50 changes: 50 additions & 0 deletions test/run-drun/issue-3140-c.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Prim = "mo:⛔";
actor {

type None = Prim.Types.None;
type Null = Prim.Types.Null;
type Bool = Prim.Types.Bool;
type Nat = Prim.Types.Nat;
type Nat8 = Prim.Types.Nat8;
type Nat16 = Prim.Types.Nat16;
type Nat32 = Prim.Types.Nat32;
type Nat64 = Prim.Types.Nat64;
type Int = Prim.Types.Int;
type Int8 = Prim.Types.Int8;
type Int16 = Prim.Types.Int16;
type Int32 = Prim.Types.Int32;
type Int64 = Prim.Types.Int64;
type Float = Prim.Types.Float;
type Char = Prim.Types.Char;
type Text = Prim.Types.Text;
type Blob = Prim.Types.Blob;
type Error = Prim.Types.Error;
type Principal = Prim.Types.Principal;

type Fresh = ?Fresh;

type T = (
None,
Null,
Bool,
Nat,
Nat8,
Nat16,
Nat32,
Nat64,
Int,
Int8,
Int16,
Int32,
Int64,
Float,
Char,
Text,
Blob,
//Error,
Principal,
Fresh
);

stable var t = [] : [T];
}
29 changes: 29 additions & 0 deletions test/run-drun/issue-3140-d.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Prim = "mo:⛔";
actor {

type Fresh = ?Fresh;
type T = (
None,
Null,
Bool,
Nat,
Nat8,
Nat16,
Nat32,
Nat64,
Int,
Int8,
Int16,
Int32,
Int64,
Float,
Char,
Text,
Blob,
//Error,
Principal,
Fresh
);

stable var t = [] : [T];
}
2 changes: 2 additions & 0 deletions test/run-drun/ok/issue-3140-c.drun-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
4 changes: 4 additions & 0 deletions test/run-drun/ok/issue-3140-c.ic-ref-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
→ update create_canister(record {settings = null})
← replied: (record {hymijyo = principal "cvccv-qqaaq-aaaaa-aaaaa-c"})
→ update install_code(record {arg = blob ""; kca_xin = blob "\00asm\01\00\00\00\0…
← replied: ()
2 changes: 2 additions & 0 deletions test/run-drun/ok/issue-3140-d.drun-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
4 changes: 4 additions & 0 deletions test/run-drun/ok/issue-3140-d.ic-ref-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
→ update create_canister(record {settings = null})
← replied: (record {hymijyo = principal "cvccv-qqaaq-aaaaa-aaaaa-c"})
→ update install_code(record {arg = blob ""; kca_xin = blob "\00asm\01\00\00\00\0…
← replied: ()

0 comments on commit 318f181

Please sign in to comment.