Skip to content

Commit

Permalink
add ability check on number constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
rahxephon89 committed Nov 21, 2024
1 parent 9fa7bae commit fd0bc1a
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,213 +1,219 @@

Diagnostics:
error: type `S` is missing required ability `key` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:28:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:32:9
15 │ fun both<R: key, C: copy>(_r: R, _c: C) {
│ - declaration of type parameter `R`
·
28 │ both(S{}, Coin{});
32 │ both(S{}, Coin{});
│ ^^^^
= required by instantiating type parameter `R:key` of function `both`

error: type `Coin` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:29:9
15 │ fun both<R: key, C: copy>(_r: R, _c: C) {
│ - declaration of type parameter `C`
·
29 │ both(0, Coin{})
│ ^^^^
error: constraint `integer` does not have required ability `key`
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:33:14
= required by instantiating type parameter `C:copy` of function `both`
33 │ both(0, Coin{})
│ ^

error: type `Box<C>` is missing required ability `key` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:33:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:37:9
15 │ fun both<R: key, C: copy>(_r: R, _c: C) {
│ - declaration of type parameter `R`
·
33 │ both(new_box<C>(), new_box<R>())
37 │ both(new_box<C>(), new_box<R>())
│ ^^^^
= required by instantiating type parameter `R:key` of function `both`

error: type `Box3<C, C, C>` is missing required ability `key` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:37:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:41:9
23 │ fun rsrc<R: key>(_r: R) {
27 │ fun rsrc<R: key>(_r: R) {
│ - declaration of type parameter `R`
·
37 │ rsrc(new_box3<C, C, C>());
41 │ rsrc(new_box3<C, C, C>());
│ ^^^^
= required by instantiating type parameter `R:key` of function `rsrc`

error: type `R` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:39:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:43:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
39 │ cpy(new_box3<R, C, C>());
43 │ cpy(new_box3<R, C, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:40:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:44:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
40 │ cpy(new_box3<C, R, C>());
44 │ cpy(new_box3<C, R, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:41:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:45:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
41 │ cpy(new_box3<C, C, R>());
45 │ cpy(new_box3<C, C, R>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:43:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:47:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
43 │ cpy(new_box3<C, R, R>());
47 │ cpy(new_box3<C, R, R>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `R` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:44:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:48:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
44 │ cpy(new_box3<R, C, R>());
48 │ cpy(new_box3<R, C, R>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `R` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:45:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:49:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
45 │ cpy(new_box3<R, R, C>());
49 │ cpy(new_box3<R, R, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `R` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:47:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:51:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
47 │ cpy(new_box3<R, R, R>());
51 │ cpy(new_box3<R, R, R>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `U` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:51:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:55:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
51 │ cpy(new_box3<U, C, C>());
55 │ cpy(new_box3<U, C, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:52:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:56:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
52 │ cpy(new_box3<C, U, C>());
56 │ cpy(new_box3<C, U, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:53:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:57:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
53 │ cpy(new_box3<C, C, U>());
57 │ cpy(new_box3<C, C, U>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `C` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:55:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:59:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
55 │ cpy(new_box3<C, U, U>());
59 │ cpy(new_box3<C, U, U>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `U` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:56:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:60:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
56 │ cpy(new_box3<U, C, U>());
60 │ cpy(new_box3<U, C, U>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `U` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:57:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:61:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
57 │ cpy(new_box3<U, U, C>());
61 │ cpy(new_box3<U, U, C>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `U` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:59:9
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:63:9
19 │ fun cpy<C: copy>(_c: C) {
23 │ fun cpy<C: copy>(_c: C) {
│ - declaration of type parameter `C`
·
59 │ cpy(new_box3<U, U, U>());
63 │ cpy(new_box3<U, U, U>());
│ ^^^
= required by instantiating type parameter `T1` of struct `Box3`
= required by instantiating type parameter `C:copy` of function `cpy`

error: type `Coin` is missing required ability `copy` (type was inferred)
┌─ tests/ability-check/v1-typing/module_call_constraints_not_satisfied.move:67:9
19 │ fun both_1<R: copy, C: key>(_r: R, _c: C) {
│ - declaration of type parameter `R`
·
67 │ both_1(Coin{}, 0)
│ ^^^^^^
= required by instantiating type parameter `R:copy` of function `both_1`
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module 0x8675309::M {
abort 0
}

fun both_1<R: copy, C: key>(_r: R, _c: C) {
abort 0
}

fun cpy<C: copy>(_c: C) {
abort 0
}
Expand Down Expand Up @@ -58,4 +62,8 @@ module 0x8675309::M {

cpy(new_box3<U, U, U>());
}

fun t4<R: key, C: drop>() {
both_1(Coin{}, 0)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

Diagnostics:
error: constraint `integer` does not have required ability `key`
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:7:27
7 │ R {r:_ } = R { r: 0 };
│ ^

error: type `Coin` is missing required ability `drop` (type was inferred)
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:8:9
Expand All @@ -11,6 +17,17 @@ error: type `Coin` is missing required ability `drop` (type was inferred)
= required by instantiating type parameter `T:drop` of struct `S`

error: type `R<*error*>` is missing required ability `key` (type was inferred)
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:12:30
3 │ struct R<T: key> { r: T }
│ - declaration of type parameter `T`
·
12 │ R {r: R { r: _ } } = R { r: R { r: 0 }};
│ ^
= required by instantiating type parameter `T:key` of struct `R`

error: type `R<key>` is missing required ability `key` (type was inferred)
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:12:30
Expand All @@ -22,6 +39,12 @@ error: type `R<key>` is missing required ability `key` (type was inferred)
= required by instantiating type parameter `T:key` of struct `R`

error: constraint `integer` does not have required ability `key`
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:12:44
12 │ R {r: R { r: _ } } = R { r: R { r: 0 }};
│ ^

error: type `Coin` is missing required ability `drop` (type was inferred)
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied.move:13:16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Diagnostics:
bug: unexpected type: _
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied2.move:6:9
error: constraint `integer` does not have required ability `key`
┌─ tests/ability-check/v1-typing/pack_constraint_not_satisfied2.move:7:27
6fun t0() {
^^
7 R {r:_ } = R { r: 0 };
^
Loading

0 comments on commit fd0bc1a

Please sign in to comment.