Skip to content

Commit

Permalink
add tests of deprecated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brmataptos committed Jun 17, 2024
1 parent 6a2e389 commit c4f3cd6
Show file tree
Hide file tree
Showing 24 changed files with 904 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Diagnostics:
error: duplicate declaration, item, or annotation
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct.move:5:11
4 │ struct C { }
│ - Alias previously defined here
5 │ const C: u64 = 0;
│ ^ Duplicate module member or alias 'C'. Top level names in a namespace must be unique

warning: unused alias
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct.move:12:15
12 │ use 0x42::mod1;
│ ^^^^ Unused 'use' of alias 'mod1'. Consider removing it

warning: unused alias
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct.move:31:15
31 │ use 0x42::mod1;
│ ^^^^ Unused 'use' of alias 'mod1'. Consider removing it

error: invalid name
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct.move:32:26
32 │ use 0x42::mod1::C as mod1;
│ ^^^^ Invalid constant alias name 'mod1'. Constant alias names must start with 'A'..'Z'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
address 0x42 {
module mod1 {
#[deprecated]
struct C { }
const C: u64 = 0;
public fun mod1() {}
}
}

address 0x41 {
module N {
use 0x42::mod1;
use 0x42::mod1::C as D;
use 0x42::mod1::C as C;
use 0x42::mod1::mod1;

fun f1(): 0x42::mod1::C {
mod1();
C;
{
use 0x42::mod1::C;
C
};
D
}
}
}


script {
use 0x42::mod1;
use 0x42::mod1::C as mod1;
use 0x42::mod1::C as C;
use 0x42::mod1::mod1;

fun f1(): 0x42::mod1::C {
mod1();
C;
{
use 0x42::mod1::C;
C
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

Diagnostics:
error: duplicate declaration, item, or annotation
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:5:11
3 │ struct C { }
│ - Alias previously defined here
4 │ #[deprecated]
5 │ const C: u64 = 0;
│ ^ Duplicate module member or alias 'C'. Top level names in a namespace must be unique

warning: unused alias
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:12:15
12 │ use 0x42::mod1;
│ ^^^^ Unused 'use' of alias 'mod1'. Consider removing it

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:13:21
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
13 │ use 0x42::mod1::C as D;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:14:21
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
14 │ use 0x42::mod1::C as C;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:17:27
4 │ #[deprecated]
│ ---------- Struct 'C' in module '0x42::mod1' deprecated here
·
17 │ fun f1(): 0x42::mod1::C {
│ ^ Use of deprecated struct 'C' from module '0x42::mod1'

warning: Use of deprecated member
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:19:2
4 │ #[deprecated]
│ ---------- Member 'C' in module '0x42::mod1' deprecated here
·
19 │ C;
│ ^ Use of deprecated member 'C' from module '0x42::mod1'

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:21:22
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
21 │ use 0x42::mod1::C;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

warning: Use of deprecated member
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:22:6
4 │ #[deprecated]
│ ---------- Member 'C' in module '0x42::mod1' deprecated here
·
22 │ C
│ ^ Use of deprecated member 'C' from module '0x42::mod1'

warning: Use of deprecated member
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:24:2
4 │ #[deprecated]
│ ---------- Member 'C' in module '0x42::mod1' deprecated here
·
24 │ D
│ ^ Use of deprecated member 'C' from module '0x42::mod1'

warning: unused alias
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:31:15
31 │ use 0x42::mod1;
│ ^^^^ Unused 'use' of alias 'mod1'. Consider removing it

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:32:21
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
32 │ use 0x42::mod1::C as mod1;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

error: invalid name
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:32:26
32 │ use 0x42::mod1::C as mod1;
│ ^^^^ Invalid constant alias name 'mod1'. Constant alias names must start with 'A'..'Z'

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:33:21
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
33 │ use 0x42::mod1::C as C;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:36:27
4 │ #[deprecated]
│ ---------- Struct 'C' in module '0x42::mod1' deprecated here
·
36 │ fun f1(): 0x42::mod1::C {
│ ^ Use of deprecated struct 'C' from module '0x42::mod1'

warning: Use of deprecated member
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:38:2
4 │ #[deprecated]
│ ---------- Member 'C' in module '0x42::mod1' deprecated here
·
38 │ C;
│ ^ Use of deprecated member 'C' from module '0x42::mod1'

warning: Use of deprecated constant
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:40:22
4 │ #[deprecated]
│ ---------- Constant 'C' in module '0x42::mod1' deprecated here
·
40 │ use 0x42::mod1::C;
│ ^ Use of deprecated constant 'C' from module '0x42::mod1'

warning: Use of deprecated member
┌─ tests/more-v1/deprecated/deprecated_constant_duplicated_struct2.move:41:6
4 │ #[deprecated]
│ ---------- Member 'C' in module '0x42::mod1' deprecated here
·
41 │ C
│ ^ Use of deprecated member 'C' from module '0x42::mod1'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
address 0x42 {
module mod1 {
struct C { }
#[deprecated]
const C: u64 = 0;
public fun mod1() {}
}
}

address 0x41 {
module N {
use 0x42::mod1;
use 0x42::mod1::C as D;
use 0x42::mod1::C as C;
use 0x42::mod1::mod1;

fun f1(): 0x42::mod1::C {
mod1();
C;
{
use 0x42::mod1::C;
C
};
D
}
}
}


script {
use 0x42::mod1;
use 0x42::mod1::C as mod1;
use 0x42::mod1::C as C;
use 0x42::mod1::mod1;

fun f1(): 0x42::mod1::C {
mod1();
C;
{
use 0x42::mod1::C;
C
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Diagnostics:
warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_field_type.move:17:22
3 │ #[deprecated]
│ ---------- Struct 'EventHandle' in module '0x42::event' deprecated here
·
17 │ use 0x42::event::EventHandle;
│ ^^^^^^^^^^^ Use of deprecated struct 'EventHandle' from module '0x42::event'

warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_field_type.move:27:25
3 │ #[deprecated]
│ ---------- Struct 'EventHandle' in module '0x42::event' deprecated here
·
27 │ deposit_events: EventHandle<DepositEvent>,
│ ^^^^^^^^^^^ Use of deprecated struct 'EventHandle' from module '0x42::event'

warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_field_type.move:28:26
3 │ #[deprecated]
│ ---------- Struct 'EventHandle' in module '0x42::event' deprecated here
·
28 │ withdraw_events: EventHandle<WithdrawEvent>,
│ ^^^^^^^^^^^ Use of deprecated struct 'EventHandle' from module '0x42::event'


============ bytecode verification succeeded ========
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module 0x42::event {

#[deprecated]
/// A handle for an event such that:
/// 1. Other modules can emit events to this handle.
/// 2. Storage can use this handle to prove the total number of events that happened in the past.
struct EventHandle<phantom T: drop + store> has store {
/// Total number of events emitted to this event stream.
counter: u64,
/// A globally unique ID for this event stream.
guid: u64,
}

}

module 0x41::coin {
use 0x42::event::EventHandle;

struct Coin<phantom T> has store { }
struct CoinType has key {}
struct DepositEvent has drop, store {}
struct WithdrawEvent has drop, store {}

struct CoinStore<phantom CoinType> has key {
coin: Coin<CoinType>,
frozen: bool,
deposit_events: EventHandle<DepositEvent>,
withdraw_events: EventHandle<WithdrawEvent>,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Diagnostics:
warning: Use of deprecated struct
┌─ tests/more-v1/deprecated/deprecated_field_type2.move:29:38
22 │ #[deprecated]
│ ---------- Struct 'WithdrawEvent' in module '0x41::coin' deprecated here
·
29 │ withdraw_events: EventHandle<WithdrawEvent>,
│ ^^^^^^^^^^^^^ Use of deprecated struct 'WithdrawEvent' from module '0x41::coin'


============ bytecode verification succeeded ========
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module 0x42::event {

/// A handle for an event such that:
/// 1. Other modules can emit events to this handle.
/// 2. Storage can use this handle to prove the total number of events that happened in the past.
struct EventHandle<phantom T: drop + store> has store {
/// Total number of events emitted to this event stream.
counter: u64,
/// A globally unique ID for this event stream.
guid: u64,
}

}

module 0x41::coin {
use 0x42::event::EventHandle;

struct Coin<phantom T> has store { }
struct CoinType has key {}
struct DepositEvent has drop, store {}

#[deprecated]
struct WithdrawEvent has drop, store {}

struct CoinStore<phantom CoinType> has key {
coin: Coin<CoinType>,
frozen: bool,
deposit_events: EventHandle<DepositEvent>,
withdraw_events: EventHandle<WithdrawEvent>,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Diagnostics:
warning: Use of deprecated module
┌─ tests/more-v1/deprecated/deprecated_placement_address.move:25:9
1 │ #[deprecated]
│ ---------- Module '0x42::M' deprecated here
·
25 │ use 0x42::M;
│ ^^^^^^^ Use of deprecated module '0x42::M'

warning: Use of deprecated module
┌─ tests/more-v1/deprecated/deprecated_placement_address.move:29:15
1 │ #[deprecated]
│ ---------- Module '0x42::M' deprecated here
·
29 │ let foo: S = M::foo();
│ ^ Use of deprecated module '0x42::M'


============ bytecode verification succeeded ========
Loading

0 comments on commit c4f3cd6

Please sign in to comment.